O'Reilly logo

Learning iOS UI Development by Yari D'areglia

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The UIAppearance protocol

If there's one thing the controls we've talked about so far have in common, it is that they can be graphically customized with the use of simple functions. This is a great a feature that has been added to UIKit since iOS5, and it allows us to modify the looks of any default control with just a few lines of code.

This feature is improved by the UIAppearance protocol that, thanks to the appearance proxy, forwards the customizations to all the instances of a specific class. The appearance proxy for a class can be retrieved using the appearance function, and as it returns instancetype, its properties can be easily accessed. Here is an example of the code needed to set onTintColor for all the UISwitch instances of an application: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required