user1872384 user1872384 - 1 year ago 174
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

font programmatically for different scenarios.

Answer Source

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];
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download