如何在标签内的单个字符串上使用多种字体样式?

-5 iphone objective-c uilabel

我有一个由 - 组成的字符串 -

lblWithText.backgroundColor = [UIColor clearColor];
    lblWithText.textColor = [UIColor blackColor];
    lblWithText.font = [UIFont fontWithName:@"Helvetica" size:12.0];
    lblWithText.text = [NSString stringWithFormat:@"Blah1:blah-blah%d. Blah2:-%d%%", [currentCoupon.couponPrice intValue],[currentCoupon.couponDiscountPercent intValue]];
Run Code Online (Sandbox Code Playgroud)

请告诉我怎么做"Blah2: - %d %%""是Bolden?先谢谢你

Har*_*hIT 6

可能这可以帮到你

单个UILabel中的粗体和非粗体文字?

它有适用于iOS 6和iOS5的解决方案,你必须使用带有NSAttributedString的CATextLayer

或者您可以参考http://www.cocoacontrols.com/platforms/ios/controls/ohattributedlabel

https://github.com/AliSoftware/OHAttributedLabel/

https://github.com/mattt/TTTAttributedLabel/