BackgroundStyle

public class BackgroundStyle

Style for background color attribute. Adding backgroundStyle attribute will add border, background and shadow as per the styles specified.

Important

This attribute is separate from backgroundColor attribute. Applying backgroundColor takes precedence over backgroundStyle i.e. the background color shows over color of backgroundStyle and will not show rounded corners.

Note

Ideally backgroundStyle may be used instead of backgroundColor as it can mimic standard background color as well as border, shadow and rounded corners.
  • Background color

    Declaration

    Swift

    public let color: UIColor
  • Rounding style for the background

    Declaration

    Swift

    public let roundedCornerStyle: RoundedCornerStyle
  • Optional border style for the background

    Declaration

    Swift

    public let border: BorderStyle?
  • Optional shadow style for the background

    Declaration

    Swift

    public let shadow: ShadowStyle?
  • Determines if the background has squared off joins at the point of wrapping of content. When set to true, the background will be squared off at inner/wrapping edges in case the background wraps across multiple lines. Defaults to false.

    Note

    This may be desirable to use in cases of short length content that is ideal to be shown as a single continued entity. When combined with RoundedCornerStyle.relative with a value of 50%, it can help mimic appearance of a broken capsule when content wraps to next line.

    Declaration

    Swift

    public let hasSquaredOffJoins: Bool
  • Defines if the background should be drawn based on height of text range with style, or that of the height of line fragment containing styled text.

    Declaration

    Swift

    public let heightMode: BackgroundMode
  • Defines if the background should be drawn based on width of text range with style, or that of the entire width of line fragment containing styled text.

    Declaration

    Swift

    public let widthMode: BackgroundMode
  • Insets for drawn background. Defaults to .zero

    Declaration

    Swift

    public let insets: UIEdgeInsets
  • Undocumented

    Declaration

    Swift

    public init(color: UIColor,
                roundedCornerStyle: RoundedCornerStyle = .absolute(value: 0),
                border: BorderStyle? = nil,
                shadow: ShadowStyle? = nil,
                hasSquaredOffJoins: Bool = false,
                heightMode: BackgroundMode = .matchLine,
                widthMode: BackgroundMode = .matchLine,
                insets: UIEdgeInsets = .zero)