iOS 获取汉字的拼音

//将NSString装换成NSMutableString 
NSMutableString *pinyin = [chinese mutableCopy];    
//将汉字转换为拼音(带音标)    
CFStringTransform((__bridge CFMutableStringRef)pinyin, NULL, kCFStringTransformMandarinLatin, NO);    
NSLog(@"带音标%@", pinyin);    
//去掉拼音的音标    
CFStringTransform((__bridge CFMutableStringRef)pinyin, NULL, kCFStringTransformStripCombiningMarks, NO);    
NSLog(@"不带音标%@", pinyin); 

//全部大写
pingyin = [pingyin uppercaseString];
//全部小写
pingyin = [pingyin lowercaseString];
//返回第一个字母
[pingyin substringToIndex:1];

你可能感兴趣的:(iOS 获取汉字的拼音)