You need to change the text color in the toolbar of the NSToolbarItem . I do this:

  NSMutableAttributedString *title = [[NSMutableAttributedString alloc] initWithString:self.label]; NSRange titleRange = NSMakeRange(0, title.length); [title addAttribute:NSForegroundColorAttributeName value:[NSColor redColor] range:titleRange]; [self setLabel:title]; 

The color changes. However, in this line [self setLabel:title] writes waring. Are there any non-curved ways to transfer an NSMutableAttributeString to an NSString ?

Warning

  • and you can read the worning? - Max Mikheyenko
  • Added to description - Ray

1 answer 1

judging by the code, you assign the UILabel object - NSMutableAttributedString. So you should not do, it is not correct, since objects of different types. Use - setAttributedText to your UILabel object.

Example: [yourLabel setAttributedText: title]

  • as far as I remember, I did it right away, but in that case, the color of the line becomes black by default - Ray
  • one
    which is because you initialized a UILabel instance, not its .text property. Check your code. NSMutableAttributedString * title = [[NSMutableAttributedString alloc] initWithString: self.label]; NSRange titleRange = NSMakeRange (0, title.length); - maxonflic