PinYin4Objc_FrameworksSupport 1.1.3

PinYin4Objc_FrameworksSupport 1.1.3

测试已测试
Lang语言 Obj-CObjective C
许可证 自定义
Released最后发布2017 年 4 月

wangrulin 维护。




  • 作者:
  • wrl

PinYin4Objc

PinYin4Objc 是一个流行的 Objective-C 库,支持将简体中文(包括繁体中文)与大多数流行的拼音系统之间进行转换,它的性能非常高效,第一次调用时进行数据缓存,您可以使用异步方法与 block,这样可以避免 UI 阻塞,并且运行顺畅。可以自定义拼音的输出格式。

更新

2013-10-08, V1.1, 添加了带有 block 的异步方法,解决了 UI 阻塞问题并修复了某些缓存错误;2013-09-16, V1.0, 首次发布。

  • 用法

1. 使用带 block 的异步方法,这可以避免 UI 阻塞,并且运行顺畅

	NSString *sourceText=@"我爱中文";
	HanyuPinyinOutputFormat *outputFormat=[[HanyuPinyinOutputFormat alloc] init];
	[outputFormat setToneType:ToneTypeWithoutTone];
	[outputFormat setVCharType:VCharTypeWithV];
	[outputFormat setCaseType:CaseTypeLowercase];    
	[PinyinHelper toHanyuPinyinStringWithNSString:sourceText 
					   withHanyuPinyinOutputFormat:outputFormat 
									   withNSString:@" " 
									   outputBlock:^(NSString *pinYin) {
  		_outputTv.text=pinYin; //update ui

	 }];

2. 使用以下同步方法

	NSString *sourceText=@"我爱中文";
	HanyuPinyinOutputFormat *outputFormat=[[HanyuPinyinOutputFormat alloc] init];
	[outputFormat setToneType:ToneTypeWithoutTone];
	[outputFormat setVCharType:VCharTypeWithV];
	[outputFormat setCaseType:CaseTypeLowercase];
	NSString *outputPinyin=[PinyinHelper toHanyuPinyinStringWithNSString:sourceText withHanyuPinyinOutputFormat:outputFormat withNSString:@" "];
  • 屏幕截图

    ScreenShot