Sep 16, 2015:  ~ 45 sec read

Changing (just) the font size of a button

We have in the app a generic button, styled to look the same across the app - from shadows to title. Some places require a smaller font though, and I didn't really want to duplicate code, so something had to be done. Here's my little trick for it:

// titleLabel is nil only for system buttons, as per documentation
button.titleLabel!.font = UIFont(
  name: button.titleLabel!.font.fontName,
  size: button.titleLabel!.font.pointSize - 2
Subscribe to my monthly newsletter.
No spam, unsubscribe at any time.