[英]NSMutableDictionary setting value crashes on iOS 5
我有以下代码:
NSMutableDictionary *attributes = [NSMutableDictionary dictionary];
[attributes setValue:[UIColor colorWithRed:86.0/255.0 green:134.0/255.0 blue:172.0/255.0 alpha:1.0] forKey:NSForegroundColorAttributeName];
它在iOS 6上正常工作,但在iOS 5上崩溃。知道为什么吗?
NSForegroundColorAttributeName仅在iOS6中可用。
所有NSAttributedString仅限于iOS6。
该NSAttributedString UIKit的添置参考了NSForegroundColorAttributeName
说:
NSForegroundColorAttributeName
此属性的值是UIColor对象。 使用此属性可以指定渲染期间文本的颜色。 如果未指定此属性,则文本将显示为黑色。
在iOS 6.0及更高版本中可用。
在NSAttributedString.h中声明。
因此,此属性仅在iOS 6及更高版本中可用。 实际上, NSAttributedString UIKit Additions中的所有内容都是iOS 6及更高版本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.