NSMutableAttributedString

extension NSMutableAttributedString
  • Applies a font to the entire string.

    Declaration

    Swift

    @discardableResult
    public func font(_ font: UIFont) -> Self

    Parameters

    font

    The font.

  • Applies a font to the entire string.

    Note: If the specified font name cannot be loaded, this method will fallback to the system font at the specified size.

    Declaration

    Swift

    @discardableResult
    public func font(name: String, size: CGFloat) -> Self

    Parameters

    name

    The font name.

    size

    The font size.

  • Applies a text alignment to the entire string.

    Declaration

    Swift

    @discardableResult
    public func alignment(_ alignment: NSTextAlignment) -> Self

    Parameters

    alignment

    The text alignment.

  • Applies line spacing to the entire string.

    Declaration

    Swift

    @discardableResult
    public func lineSpacing(_ lineSpacing: CGFloat) -> Self

    Parameters

    lineSpacing

    The line spacing amount.

  • Applies paragraph spacing to the entire string.

    Declaration

    Swift

    @discardableResult
    public func paragraphSpacing(_ paragraphSpacing: CGFloat) -> Self

    Parameters

    paragraphSpacing

    The paragraph spacing amount.

  • Applies a line break mode to the entire string.

    Declaration

    Swift

    @discardableResult
    public func lineBreak(_ mode: NSLineBreakMode) -> Self

    Parameters

    mode

    The line break mode.

  • Applies a line height multiplier to the entire string.

    Declaration

    Swift

    @discardableResult
    public func lineHeight(multiple: CGFloat) -> Self

    Parameters

    multiple

    The line height multiplier.

  • Applies a first line head indent to the string.

    Declaration

    Swift

    @discardableResult
    public func firstLineHeadIndent(_ indent: CGFloat) -> Self

    Parameters

    indent

    The first line head indent amount.

  • Applies a head indent to the string.

    Declaration

    Swift

    @discardableResult
    public func headIndent(_ indent: CGFloat) -> Self

    Parameters

    indent

    The head indent amount.

  • Applies a tail indent to the string.

    Declaration

    Swift

    @discardableResult
    public func tailIndent(_ indent: CGFloat) -> Self

    Parameters

    indent

    The tail indent amount.

  • Applies a minimum line height to the entire string.

    Declaration

    Swift

    @discardableResult
    public func minimumLineHeight(_ height: CGFloat) -> Self

    Parameters

    height

    The minimum line height.

  • Applies a maximum line height to the entire string.

    Declaration

    Swift

    @discardableResult
    public func maximumLineHeight(_ height: CGFloat) -> Self

    Parameters

    height

    The maximum line height.

  • Applies a base writing direction to the entire string.

    Declaration

    Swift

    @discardableResult
    public func baseWritingDirection(_ direction: NSWritingDirection) -> Self

    Parameters

    direction

    The base writing direction.

  • Applies a paragraph spacing before amount to the string.

    Declaration

    Swift

    @discardableResult
    public func paragraphSpacingBefore(_ spacing: CGFloat) -> Self

    Parameters

    spacing

    The distance between the paragraph’s top and the beginning of its text content.

  • Applies the given color over the entire string, as the foreground color.

    Declaration

    Swift

    @discardableResult
    @nonobjc
    public func color(_ color: UIColor, alpha: CGFloat = 1) -> Self

    Parameters

    color

    The color to apply.

  • Applies the given color over the entire string, as the foreground color.

    Declaration

    Swift

    @discardableResult
    public func color(red: CGFloat, green: CGFloat, blue: CGFloat, alpha: CGFloat = 1) -> Self

    Parameters

    color

    The color to apply.

  • Applies the given color over the entire string, as the foreground color.

    Declaration

    Swift

    @discardableResult
    public func color(white: CGFloat, alpha: CGFloat = 1) -> Self

    Parameters

    color

    The color to apply.

  • Applies the given color over the entire string, as the foreground color.

    Declaration

    Swift

    @discardableResult
    @nonobjc
    public func color(_ hex: UInt32, alpha: CGFloat = 1) -> Self

    Parameters

    color

    The color to apply.

  • Applies a single underline under the entire string.

    Declaration

    Swift

    @discardableResult
    public func underline(style: NSUnderlineStyle = .single, color: UIColor? = nil) -> Self

    Parameters

    style

    The NSUnderlineStyle to apply. Defaults to .styleSingle.

  • Applies a kern (spacing) value to the entire string.

    Declaration

    Swift

    @discardableResult
    public func kern(_ value: CGFloat) -> Self

    Parameters

    value

    The space between each character in the string.

  • Applies a strikethrough to the entire string.

    Declaration

    Swift

    @discardableResult
    public func strikethrough(style: NSUnderlineStyle = .single, color: UIColor? = nil) -> Self

    Parameters

    style

    The NSUnderlineStyle to apply. Defaults to .styleSingle.

    color

    The underline color. Defaults to the color of the text.

  • Applies a stroke to the entire string.

    Declaration

    Swift

    @discardableResult
    public func stroke(color: UIColor, width: CGFloat) -> Self

    Parameters

    color

    The stroke color.

    width

    The stroke width.

  • Applies a shadow to the entire string.

    Declaration

    Swift

    @discardableResult
    public func shadow(color: UIColor, radius: CGFloat, offset: CGSize) -> Self

    Parameters

    color

    The shadow color.

    radius

    The shadow blur radius.

    offset

    The shadow offset.

  • Applies a background color to the entire string.

    Declaration

    Swift

    @discardableResult
    @nonobjc
    public func backgroundColor(_ color: UIColor, alpha: CGFloat = 1) -> Self

    Parameters

    color

    The color to apply.

  • Applies a background color to the entire string.

    Declaration

    Swift

    @discardableResult
    public func backgroundColor(red: CGFloat, green: CGFloat, blue: CGFloat, alpha: CGFloat = 1) -> Self

    Parameters

    red

    The red color component.

    green

    The green color component.

    blue

    The blue color component.

    alpha

    The alpha component.

  • Applies a background color to the entire string.

    Declaration

    Swift

    @discardableResult
    public func backgroundColor(white: CGFloat, alpha: CGFloat = 1) -> Self

    Parameters

    white

    The white color component.

    alpha

    The alpha component.

  • Applies a background color to the entire string.

    Declaration

    Swift

    @discardableResult
    @nonobjc
    public func backgroundColor(_ hex: UInt32, alpha: CGFloat = 1) -> Self

    Parameters

    hex

    The hex color value.

    alpha

    The alpha component.

  • Applies a baseline offset to the entire string.

    Declaration

    Swift

    @discardableResult
    public func baselineOffset(_ offset: Float) -> Self

    Parameters

    offset

    The offset value.