gpt4 book ai didi

objective-c - iOS 6 之前的 NSAttributedString 是否可用?

转载 作者:技术小花猫 更新时间:2023-10-29 11:13:06 24 4
gpt4 key购买 nike

我发现有关 NSAttributedString 6 之前的 iOS 版本可用性的信息相互矛盾。如果它向后兼容,这将是非常有用的东西。

这里说它从 iOS 4 开始可用: Why No NSAttributedString on the iPhone?

Apple 网站上写着 iOS 6 及更高版本:https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSAttributedString_Class/Reference/Reference.html

我尝试像这样在我的代码中实现它:

NSAttributedString *commentString = [[NSAttributedString alloc] initWithString:@"I really love raisins" attributes:@{NSForegroundColorAttributeName: [UIColor blackColor]}];

它在 iOS 6 中有效,但当我尝试在 iOS 5 或 iOS 5.1 中运行时无效。我没有测试过早期版本。

我只是想使用旧版本中不包含的功能吗?

最佳答案

从iOS3.2开始就有了。然而,在某些 UI 控件(如 UILabel、UIButton、UITextView 等)中使用它们的能力仅在 iOS6 之后可用。您仍然可以使用适用于 < 6.0 的 CoreText 来使用它们。

关于objective-c - iOS 6 之前的 NSAttributedString 是否可用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13389647/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com