Contents

addAttributes(_:range:)

Adds the given collection of attributes to the characters in the specified range.

Declaration

func addAttributes(_ attrs: [NSAttributedString.Key : Any] = [:], range: NSRange)

Parameters

  • attrs:

    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 Nsattributedstring.

  • range:

    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 invalidArgumentException if attrs is nil and an rangeException if any part of range lies beyond the end of the receiver’s characters.

See Also

Changing Attributes