获取汉字的大写首字母

2015-11-02  本文已影响0人  陈兔兔

NSString *name = @"陈";

NSMutableString *str = [NSMutableString stringWithString:name];

CFStringTransform((CFMutableStringRef)str,NULL, kCFStringTransformMandarinLatin,NO);

//再转换为不带声调的拼音

CFStringTransform((CFMutableStringRef)str,NULL, kCFStringTransformStripDiacritics,NO);

//转化为大写拼音

NSString *pinYin = [str capitalizedString];

NSString *Frist = [pinYin stringByPaddingToLength:1 withString:pinYin startingAtIndex:0];

NSLog(@"pinYin = %@", Frist);

上一篇下一篇

猜你喜欢

热点阅读