NSAttributedString

extension NSAttributedString
  • Returns an attributed string consisting of the attributed string’s text with the specified attributes applied to the entire range and then the attributed string’s attributes copied on top of that.

    Declaration

    Swift

    public func attributedString(with baseAttributes: [NSAttributedString.Key : Any]) -> NSAttributedString

    Parameters

    baseAttributes

    the attributes to apply to the entire range

    Return Value

    An attributed string with the universal attributes applied beneath the attributed string’s own attributes

  • Applies a text case to an attributed string.

    Applying capitalized (Title Case) may be problematic because it is applied in fragments according to the attributes. So “John” could become “JoHn” if an attribute were applied only to first two or last two letters. But we have to do it this way because capitalization operations are not guaranteed to be symmetrical. e.g. “straße”.uppercased() == “STRASSE”.

    Declaration

    Swift

    public func textCase(_ textCase: Typography.TextCase) -> NSAttributedString

    Parameters

    textCase

    the text case to apply

    Return Value

    the updated attributed string