I'm trying to use a variable font on a label in UI...
# ios
d
I'm trying to use a variable font on a label in UIKitView, but the variations are not applying. What could I be doing wrong?
Copy code
val baseFont = UIFont.preferredFontForTextStyle(UIFontTextStyleLargeTitle)                

val variations = mapOf(
                    2003265652 to 900, // wght
                    2003072104 to 140 // wdth
                )

                val fontAttributes = mapOf(
                    UIFontDescriptorAttributeName to baseFont.fontName,
                    "NSCTFontVariationAttribute" as UIFontDescriptorAttributeName to variations
                )

                val descriptor = baseFont.fontDescriptor.fontDescriptorByAddingAttributes(fontAttributes)
                val variableFont = UIFont.fontWithDescriptor(descriptor, baseFont.pointSize)

                label.font = variableFont