Nov 01, 2018:  ~ 1 min read

Easier UIFont usage

In a previous post I was writing about improving working with UIFont and now I’d like to take it one step further in regards with having a quick and easy way to set fonts, if you use a single typeface (font family):

extension UIFont {

   static func regular(_ size: CGFloat) -> UIFont {
      return .systemFont(ofSize: size, weight: .regular) // Or any other font.
   static func medium(_ size: CGFloat) -> UIFont {
      return .systemFont(ofSize: size, weight: .medium)


This might not seem much, or maybe I’m just lazy, but I find it easier to write and read

let nameLabel = UILabel()
nameLabel.font = .regular(15)


let nameLabel = UILabel()
nameLabel.font = .systemFont(ofSize: size, weight: .regular)
Subscribe to my monthly newsletter.
No spam, unsubscribe at any time.