如何使用範圍屬性初始化NSAttributedString
?按照現狀,我只能在初始化後才知道如何添加一個ranged屬性,這顯然不適用於不可變的NSAttributedString
實例。如何創建具有範圍屬性的不可變NSAttributedString
如果我有一個NSMutableAttributedString
,我可以打電話:
[str addAttribute:NSLinkAttributeName value:url range:range];
如果我有一個NSAttributedString
,我可以構建它:
[[NSAttributedString alloc] initWithString:str attributes:@{NSLinkAttributeName: url}];
但我不能找到一種方法,把範圍到attributesDict。
感謝,