TextStyle class

TextStyle class consists of following parameters. Required parameters must be set at initialisation.

Parameters Required

ParameterTypeDescription
textStringString text
let textStyle = TextStyle(text: "Cancel payment")

Parameters Optional

ParameterTypeDescription
colorStringHEX value color of text
fontUIFontText font
sizeCGFloat?Text font size
weightUIFont.Weight?Text font weight

Example

var buttonStyle = ButtonStyle(type: .text)

// Default font example:
var textStyle = TextStyle(text: "Close payment", size: 15, weight: .semibold)

// Custom font example:
// var textStyle = TextStyle(text: "Close payment", fontName: "Arial-Bold", size: 15)

textStyle.color = "0476BA"
buttonStyle.textStyle = textStyle

Adding a Custom Font to your iOS app

Apple - Adding a Custom Font to Your App

Example

guard let customFont = UIFont(name: "CustomFont-Light", size: UIFont.labelFontSize) else {
    fatalError("""
        Failed to load the "CustomFont-Light" font.
        Make sure the font file is included in the project and the font name is spelled correctly.
        """
    )
}

var buttonStyle = ButtonStyle(type: .text)

var textStyle = TextStyle(text: "Close payment", font: customFont)

textStyle.color = "0476BA"
buttonStyle.textStyle = textStyle