iOS: A Beautiful Way of Styling IBOutlets in Swift

This morning I saw a beautiful tweet from @jesse_squires:

Settings colors, fonts, and accessibility for UI elements in apps is always in pain. Ideally this would happen in the storyboard, but color management in the storyboard is pretty horrible (one way to mitigate this is through an Xcode Color Palette), and more advanced accessibility stuff can’t even be done in the storyboard.

So I personally prefer to do this in code – much easier to see where all the colors / font / accessibility / etc changes need to be made when the app is re-designed. I often see this translated into a super long viewDidLoad as Jesse mentions, which I try to extract into one or more functions in private extension in Swift like this:

But I really love the readability and simplicity of Jesse’s solution:

Time to refactor!

Enjoy the article? Join over 20,000+ Swift developers and enthusiasts who get my weekly updates.