我想让文本字符串的某些部分变为粗体。
Eg: 这就是要大胆。这是正常的字符串。
在Android中,可以通过使用可生成字符串轻松实现。 iOS 中的等价物是什么?
是的,可以通过以下方式实现NSAttributedString https://developer.apple.com/library/ios/documentation/Cocoa/Reference/Foundation/Classes/NSAttributedString_Class/index.html:
NSString *yourString = @"This is to be bold. This is normal string.";
NSMutableAttributedString *yourAttributedString = [[NSMutableAttributedString alloc] initWithString:yourString];
NSString *boldString = @"This is to be bold";
NSRange boldRange = [yourString rangeOfString:boldString];
[yourAttributedString addAttribute: NSFontAttributeName value:[UIFont boldSystemFontOfSize:12] range:boldRange];
[yourLabel setAttributedText: yourAttributedString];
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)