Contents

setAttributes(_:range:)

Sets the attributes for the characters in the specified range to the specified attributes.

Declaration

func setAttributes(_ attrs: [NSAttributedString.Key : Any]?, range: NSRange)

Parameters

  • attrs:

    A dictionary containing the attributes to set. 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 whose attributes are set.

Discussion

These new attributes replace any attributes previously associated with the characters in range. Raises an rangeException if any part of range lies beyond the end of the receiver’s characters.

To set attributes for a zero-length NSMutableAttributedString displayed in a text view, use the NSTextView method typingAttributes.

See Also

Changing Attributes