Gregor Žavcer
Gregor Žavcer

Reputation: 23

iOS: Dynamically change font weight and bluriness of UILabel

I've been looking at answers and documentation but can't find anything on this topic. I'm fairly new to IOS development, so hopefully this question is relevant for here.

I have a TableView where user swipes right on a cell and font size of the label increases. However, in order to make it according to design specs I would also need to increase font weight. This is what I currently use:

self.infoLabel.font = [UIFont fontWithName:self.textLabel.font.familyName size:20 + 20*_intensityPercentage];

Other methods I've looked at seem to only switch bold on/off, however I'd need to adjust it continously.

Another problem with TableViewCell I'm facing is that UILabel would become blurier with left swipe. Is that even possible to do?

Any help is much appreciated. Thank you!

Upvotes: 2

Views: 4165

Answers (1)

TomSwift
TomSwift

Reputation: 39512

Per Is there a medium weight font between -systemFontOfSize: and -boldSystemFontOfSize:?, iOS doesn't support dynamic font weight. But since many fonts that ship with iOS ship with 3 or more "weights" within the font family you likely have more control available than normal / bold. For example, you might be able to dynamically rotate through HelveticaNeue-UltraLight to HelveticaNeue-Light to HelveticaNeue to HelveticaNeue-Medium to HelveticaNeue-Bold.

Check out http://www.iosfonts.com for a good dump of what fonts and weights are available to different versions of iOS.

Upvotes: 4

Related Questions