这个问题已经在这里有答案 :
可能重复:
TTT归因标签多彩色字体的帮助
我怎样才能做到喜欢这幅画在iphone? 任何人帮助我。 我应该使用核心动画或文本的核心还是别的什么? http://s7.postimage.org/qgbhw7c3v/Capture.png
这个问题已经在这里有答案 :
可能重复:
TTT归因标签多彩色字体的帮助
我怎样才能做到喜欢这幅画在iphone? 任何人帮助我。 我应该使用核心动画或文本的核心还是别的什么? http://s7.postimage.org/qgbhw7c3v/Capture.png
NSString *test = @"How can i Do that? (just only one string and don't devided into 2 part)";
CFStringRef string = (CFStringRef) test;
CFMutableAttributedStringRef attrString = CFAttributedStringCreateMutable(kCFAllocatorDefault, 0);
CFAttributedStringReplaceString (attrString,CFRangeMake(0, 0), string);
/*
Note: we could have created CFAttributedStringRef which is non mutable, then we would have to give all its
attributes right when we create it. We can change them if we use mutable form of CFAttributeString.
*/
CGColorRef _red=[UIColor redColor].CGColor;
CFAttributedStringSetAttribute(attrString, CFRangeMake(0, 11),kCTForegroundColorAttributeName, _red);
注 =>添加CoreText框架项目和导入。
您可以使用OHAtrributedLabel这个简单而有效: https://github.com/AliSoftware/OHAttributedLabel