iphoneiosnsattributedstring

Changing Background color on NSAttributedString


I just wanted to know how could i change the background color of an NSAttributedString, i can see the background being white all the time, but i want to make it black.

Is that possible?? Many thanks!


Solution

  • I think you want NSBackgroundColorAttributeName. Such as:

    [mutableAttributedString addAttribute:NSBackgroundColorAttributeName value:[UIColor yellowColor] range:selectedRange];