iOS - Access Theme Fonts
note
Modules conforming to the Module
interface can access an instance of ModuleDataSource
via the moduleDataSource
property.
Use this instance to retrieve the theme fonts consumed by Q2MobileCore
. :::
To retrieve the current theme fonts used by Q2MobileCore
, use the ThemeProvider
available through the theme
property in the ModuleDataSource
interface.
Example
Use the following code snippet to get a font of the specified size:
Accessing Theme Font
let themeFont = moduleDataSource?.theme?.font(withSize: 12)
let uiThemeFont = themeFont.uiFont
Helper
The ThemeFontHelper class provides various font styles that can be accessed easily.
ThemeFontHelper
let appFont = ThemeFontHelper.appFont(ofSize: CGFloat) -> UIFont
let boldAppFont = ThemeFontHelper.boldAppFont(ofSize: CGFloat) -> UIFont
let italicAppFont = ThemeFontHelper.italicAppFont(ofSize: CGFloat) -> UIFont
let semiBoldAppFont = ThemeFontHelper.semiBoldAppFont(ofSize: CGFloat) -> UIFont
let lightAppFont = ThemeFontHelper.lightAppFont(ofSize: CGFloat) -> UIFont