UIKit Fundamentals: Build v1.0 of the MemeMe App / NSAttributedStrings

This rant is not about the UIKit Fundamentals course per se, but rather the difficulty of finding decent documentation on the NSAttributedString class. If you are looking for it, here it is: NSAttributedString iOS Swift. You will note that link does not go to developer.apple.com. The information needed for the v1.0 build of the MemeMe app may be on Apple’s website, but I spent a great deal of time not finding it.

The particular bit of needed information I was looking for is not easily guessed either, as it is both complicated and non-intuitive:

  • NSStrokeWidthAttributeName will override NSForegroundColorAttributeName, such that the foreground color is clear, if the specified stroke width is positive.
  • NSStrokeWidthAttributeName with a negative stroke width on the other hand will use the NSForegroundColorAttributeName as the fill color.

Kudos to Eva Diaz-Santana (@evdiasan) for providing that information on a web page that is everything Apple should have provided easy reference to from the NSAttributedString class documentation: a clear, visual representation of just what all of those attributes mean and how to use them.

Leave a Reply

Your email address will not be published. Required fields are marked *