Is NSAttributedString available before iOS 6?

前端 未结 3 1290
甜味超标
甜味超标 2021-01-11 23:15

I have found conflicting information on the availability of NSAttributedString for iOS versions before 6. It is something that would be really useful if it is somewhat back

3条回答
  •  长情又很酷
    2021-01-11 23:49

    NSAttributeString and the initWithString:attributes: method have been around since iOS 3.2 according to the iOS reference docs. Some method of NSAttributedString were added in iOS 4.0. All of the methods added as a UIKit category were added in iOS 6.0.

    The problem with this line:

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

    is that the NSForegroundColorAttributeName constant wasn't added until iOS 6.0.

    So while NSAttributedString has been around for a while, all of the useful stuff wasn't added until 6.0.

提交回复
热议问题