user1872384 user1872384 - 6 days ago 6
Objective-C Question

How to set WKInterfaceButton font programmatically?

Currently I can adjust the font type and size via storyboard. However, I want to set

WKInterfaceButton
font programmatically for different scenarios.

Answer

You can do this via NSAttributedString

UIFont * buttonFont = [UIFont fontWithName:@"Courier-Bold" size:6];
NSAttributedString *buttonText = [[NSAttributedString alloc] initWithString : @"Your button title" attributes : @{ NSKernAttributeName : @2.0, NSFontAttributeName : buttonFont}];
[self.button setAttributedTitle:buttonText];
Comments