TypographyButton

open class TypographyButton : UIButton

Button that supports Typography. You can optionally set maximumPointSize or maximumScaleFactor to set a cap on Dynamic Type scaling.

  • The current typographical layout

    Declaration

    Swift

    public private(set) var layout: TypographyLayout! { get }
  • Typography to be used for this buttons’s title label

    Declaration

    Swift

    public var typography: Typography { get set }
  • (Optional) maximum point size when scaling the font.

    Value should be greater than Typography.fontSize. nil means no maximum for scaling. Has no effect for fixed Typography.

    If you wish to set a specific maximum scale factor instead of a fixed maximum point size, set maximumScaleFactor instead. maximumScaleFactor will be used if both properties are non-nil.

    Declaration

    Swift

    public var maximumPointSize: CGFloat? { get set }
  • (Optional) maximum scale factor to use when scaling the font.

    Value should be greater than 1. nil means no maximum scale factor. Has no effect for fixed Typography.

    If you wish to set a specific maximum point size instead of a scale factor, set maximumPointSize instead. Takes precedence over maximumPointSize if both properties are non-nil.

    Declaration

    Swift

    public var maximumScaleFactor: CGFloat? { get set }
  • Initializes a button using the specified Typography

    Declaration

    Swift

    required public init(typography: Typography)

    Parameters

    typography

    the font information to use

  • Initializes a button using the default Typography Typography.systemButton

    Declaration

    Swift

    required public init?(coder: NSCoder)
  • Gets or sets the text alignment of the button’s title label. Default value = .natural

    Declaration

    Swift

    public var textAlignment: NSTextAlignment { get set }
  • Gets or sets the line break mode of the button’s title label. Default value = .byTruncatingTail

    Declaration

    Swift

    public var lineBreakMode: NSLineBreakMode { get set }
  • Call this if you’ve made a change that would require text to be re-styled. (Normally this is not necessary). Override this if you need to do something additional when preferred content size or legibility weight has changed

    Declaration

    Swift

    open func adjustFonts()
  • Override this if you have colors that will not automatically adjust to Light / Dark mode, etc. This can be the case for CGColor or non-template images (or backgroundImages).

    Declaration

    Swift

    open func adjustColors()
  • Override this if you have typography that might change at different breakpoints. You should check .window?.bounds.size for potential changes.

    Declaration

    Swift

    open func adjustBreakpoint()