繁体   English   中英

NSMutableDictionary设置值在iOS 5上崩溃

[英]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中可用。

http://developer.apple.com/library/ios/#Documentation/UIKit/Reference/NSAttributedString_UIKit_Additions/Reference/Reference.html

所有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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM