The documentation for kCTUnderlineStyleAttributeName passes the following:
kCTUnderlineStyleAttributeName The underline style that will be applied during rendering for the text to which this attribute applies. The value must be a CFNumber object. The default is kCTUnderlineStyleNone. Set a value other than kCTUnderlineStyleNone to draw an underline. In addition, the constants listed in CTUnderlineStyleModifiers can be used to change the appearance of the underline. The color of the underline is determined by the color of the foreground text.
The signature for the setAttributes function is as follows:
func setAttributes(attrs: [NSObject : AnyObject]?, range: NSRange)
The problem I ran into is that the documentation seems to refer to the fact that CTUnderlineStyle.Single can (and should be in Swift) be used as the value for kCTUnderlineStyleAttributeName . However, the former is a structure and, as a result, does not correspond to the AnyObject protocol required by the value type of dictionaries.
Any ideas?
source
share