Search code examples
iosswiftuikitnsshadow

NSShadow set() method in iOS


In Apple's documentation for NSShadow in UIKit, they state:

An NSShadow object may be used in one of two ways. First, it may be set, like a color or a font, in which case its attributes are applied to all content drawn thereafter—or at least until another shadow is applied or a previous graphics state is restored.

But NSShadow does not appear to have a set() method, at least with UIKit. Am I missing something, or is this a mistake on Apple's part (possible due to being copied verbatim from the AppKit Mac OS X NSShadow documentation)?

Is there any way to achieve the set() behaviour, or are NSAttributedStrings the only thing NSShadow is useful for in UIKit?


Solution

  • Is there any way to achieve the set() behaviour

    Not with NSShadow. Keep in mind, though, that all UIKit drawing is just a convenience for using CoreGraphics directly, which is where all the real action is anyway. Thus, for drawing in general, call CGContextSetShadow.