NSAttributedString

public extension NSAttributedString

API initializers from array of tuples (string, attr, …)

  • Initialize from an array of strings with color, joining with the separator

    Declaration

    Swift

    convenience init(stringsWithColor: [(String, UIColor)], separator: String = " ")

    Parameters

    stringsWithStyle

    array of tuples (string, color)

    separator

    string

  • Initialize from an array of strings with styles, joining with the separator

    Declaration

    Swift

    convenience init(stringsWithStyle: [(String, UIFont.TextStyle)], separator: String)

    Parameters

    stringsWithStyle

    array of tuples (string, style)

    separator

    string

  • Initialize from an array of strings with styles and weights, joining with the separator

    Declaration

    Swift

    convenience init(stringsWithStyleAndWeight: [(String, UIFont.TextStyle, weight: UIFont.Weight)], separator: String)

    Parameters

    stringsWithStyle

    array of tuples (string, style)

    separator

    string

    weight

    font weight, e.g. .thin

INTERNAL simple initializers from string and specific attributes

  • Initialize from a string using the fgColor

    Declaration

    Swift

    convenience init(string: String, fgColor: UIColor)

    Parameters

    string

    input string

    color

    foreground color

  • Initialize from a string using the textStyle

    Declaration

    Swift

    convenience init(string: String, textStyle: UIFont.TextStyle)

    Parameters

    string

    input string

    textStyle

    input font text style

  • Initialize from a string using the textStyle and weight

    Declaration

    Swift

    convenience init(string: String, textStyle: UIFont.TextStyle, weight: UIFont.Weight)

    Parameters

    string

    input string

    textStyle

    input font text style

    weight

    font weight, e.g. .thin

INTERNAL initializer with arrays of NSAttributedString

  • Initialize from an array of NSAttributedString, joining with the separator

    Declaration

    Swift

    convenience init(from nsaStrings: [NSAttributedString], separator: String)

    Parameters

    nsaStrings

    array of attributes strings

    separator

    input separator