Default color / font NSAttributedString etc.

I am using drawGlyphsForGlyphRange to render NSAttributedString (in NSView drawRect )

Is there any way to set the color / font, etc. NSAttributedString ? It is clear that I could set these values ​​specifically for this range, but then override any specific settings in the line. I had a feeling that I had a fundamental misunderstanding of how NSAttributedStrings should be used !!

thanks

+4
source share
1 answer

The default font for NSAttributedString objects is the 12-point Helvetica key on iOS and Lucida Grande (or something else that is set by default for the system font) in OS X. Use initWithString:attributes: to create an NSAttributedString with some predefined attributes that initially apply to the entire row. Any attributes that you set for different ranges of your string will complement / replace the attributes that you define when creating your instance of NSAttributedString.

+7
source

Source: https://habr.com/ru/post/1441531/


All Articles