NSAttributedString

public extension NSAttributedString
  • SwifterSwift: Bolded string.

    Declaration

    Swift

    var bolded: NSAttributedString { get }
  • SwifterSwift: Underlined string.

    Declaration

    Swift

    var underlined: NSAttributedString { get }
  • SwifterSwift: Italicized string.

    Declaration

    Swift

    var italicized: NSAttributedString { get }
  • SwifterSwift: Struckthrough string.

    Declaration

    Swift

    var struckthrough: NSAttributedString { get }
  • SwifterSwift: Dictionary of the attributes applied across the whole string

    Declaration

    Swift

    var attributes: [NSAttributedString.Key : Any] { get }

Methods

  • SwifterSwift: Add color to NSAttributedString.

    Declaration

    Swift

    func colored(with color: Color) -> NSAttributedString

    Parameters

    color

    text color.

    Return Value

    a NSAttributedString colored with given color.

  • SwifterSwift: Apply attributes to substrings matching a regular expression

    Declaration

    Swift

    func applying(attributes: [NSAttributedString.Key: Any],
                  toRangesMatching pattern: String,
                  options: NSRegularExpression.Options = []) -> NSAttributedString

    Parameters

    attributes

    Dictionary of attributes

    pattern

    a regular expression to target

    options

    The regular expression options that are applied to the expression during matching. See NSRegularExpression.Options for possible values.

    Return Value

    An NSAttributedString with attributes applied to substrings matching the pattern

  • SwifterSwift: Apply attributes to occurrences of a given string

    Declaration

    Swift

    func applying<T>(attributes: [NSAttributedString.Key : Any], toOccurrencesOf target: T) -> NSAttributedString where T : StringProtocol

    Parameters

    attributes

    Dictionary of attributes

    target

    a subsequence string for the attributes to be applied to

    Return Value

    An NSAttributedString with attributes applied on the target string

Operators

  • SwifterSwift: Add a NSAttributedString to another NSAttributedString.

    Declaration

    Swift

    static func += (lhs: inout NSAttributedString, rhs: NSAttributedString)

    Parameters

    lhs

    NSAttributedString to add to.

    rhs

    NSAttributedString to add.

  • SwifterSwift: Add a NSAttributedString to another NSAttributedString and return a new NSAttributedString instance.

    Declaration

    Swift

    static func + (lhs: NSAttributedString, rhs: NSAttributedString) -> NSAttributedString

    Parameters

    lhs

    NSAttributedString to add.

    rhs

    NSAttributedString to add.

    Return Value

    New instance with added NSAttributedString.

  • SwifterSwift: Add a NSAttributedString to another NSAttributedString.

    Declaration

    Swift

    static func += (lhs: inout NSAttributedString, rhs: String)

    Parameters

    lhs

    NSAttributedString to add to.

    rhs

    String to add.

  • SwifterSwift: Add a NSAttributedString to another NSAttributedString and return a new NSAttributedString instance.

    Declaration

    Swift

    static func + (lhs: NSAttributedString, rhs: String) -> NSAttributedString

    Parameters

    lhs

    NSAttributedString to add.

    rhs

    String to add.

    Return Value

    New instance with added NSAttributedString.