iphone - OHAttributedLabel numberOfLines

标签 iphone ios

引用OHAttributedLabel numberOfLines问题。我创建了一个 OHAttributedLabel 并在设置 attributedText 时我的应用程序崩溃了。标签上显示的文本可能是多行,因为它来自服务器。
解决方案是什么?

NSMutableAttributedString* attrStr = [NSMutableAttributedString attributedStringWithString:string];
[attrStr setTextColor:[UIColor colorWithRed:0.f green:0.f blue:0.5 alpha:1.f] range:[string rangeOfString:matchingStringPhone]];
            label.attributedText = attrStr;  

在第二行崩溃。

最佳答案

编译器应该警告你类 NSMutableAttributedString 中没有 setTextColor:range: 方法。
至少我的是这样做的。
你的?

也许你想调用
- (void)setAttributes:(NSDictionary *)attributes range:(NSRange)aRange
???

关于iphone - OHAttributedLabel numberOfLines,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8855382/

相关文章:

ios - 将 PixelBuffer(kCVPixelFormatType_420YpCbCr8Planar) 转换为 CIImage

iOS 通用链接不适用于 Gmail 应用程序

iphone - NSMutableString appendString 生成一个 SIGABRT

ios - 在 UITableview 中添加 UITextField

ios - Apple Watch 是否可以直接从 Web 服务器获取数据,而无需 iPhone 作为中介?

ios - 空 UIView 上的自动布局约束无法按预期工作

ios - 有没有办法拦截应用程序中的音频输出以在 iOS 上显示音频可视化工具?

iphone - 如何在xcode中调用多个web服务

iphone - 通过 Flex 访问 iOS API 的技巧?

ios - 快速删除图像文件,抛出文件不存在