YCPinYin
Example
To run the example project, clone the repo, and run pod install
from the Example directory first.
Requirements
Installation
Installation with CocoaPods
YCEasyTool is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "YCPinYin"
Installation with Carthage
Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.
You can install Carthage with Homebrew using the following command:
$ brew update
$ brew install carthage
To integrate YCPinYin
into your Xcode project using Carthage, specify it in your Cartfile
:
github "ungacy/YCPinYin"
Run carthage
to build the frameworks and drag the appropriate framework (YCPinYin.framework
) into your Xcode project according to your need. Make sure to add only one framework and not both.
Usage
首字母
设置输出格式,初始化一次就好.
[YCPinYin sharedInstance].defaultFormat = YCPinYinOutoutFormatFirstLetter;
用吧
NSString *string = @"你好";
NSString *pinyin = [string yc_toPinYin];//nh
NSParameterAssert([pinyin isEqualToString:@"nh"]);
全部字母
设置输出格式,初始化一次就好.
[YCPinYin sharedInstance].defaultFormat = YCPinYinOutoutFormatAllLetter;
用吧
NSString *string = @"你好";
NSString *pinyin = [string yc_toPinYin];//nihao
NSParameterAssert([pinyin isEqualToString:@"nihao"]);
首字母+全部字母
设置输出格式,初始化一次就好.
[YCPinYin sharedInstance].defaultFormat = YCPinYinOutoutFormatDefault;
or
[YCPinYin sharedInstance].defaultFormat = YCPinYinOutoutFormatAllLetter | YCPinYinOutoutFormatFirstLetter;
用吧
NSString *string = @"你好";
NSString *pinyin = [string yc_toPinYin];//nh#nihao
NSParameterAssert([pinyin isEqualToString:@"nh#nihao"]);
声调
感觉用处不多,见demo
更多
见demo
Author
ungacy, [email protected]
License
YCPinYin is available under the MIT license. See the LICENSE file for more info.