Adds the given collection of attributes to the characters in the specified range.
SDKs
- iOS 3.2+
- macOS 10.0+
- tvOS 9.0+
- watchOS 2.0+
Framework
- Foundation
Declaration
func addAttributes(_ attrs: [NSAttributed String.Key : Any] = [:], range: NSRange)
Parameters
attributes
A dictionary containing the attributes to add. Attribute keys can be supplied by another framework or can be custom ones you define. For information about the system-supplied attribute keys, see the Constants section in
NSAttributed
.String aRange
The range of characters to which the specified attributes apply.
Discussion
You may assign any name/value pair you wish to a range of characters. Raises an invalid
if attributes
is nil
and an range
if any part of a
lies beyond the end of the receiver’s characters.