Improving Readability of UIAppearance Code With UISS
UIAppearance is a convenient way to define styles for UIKit classes throughout your application. For example, instead of setting the font on every UILabel, you can define it once using a UIAppearance proxy:
Of course this is Objective-C, so the UIAppearance code is verbose and can be quite difficult to read. If you work with a designer who might like to tweak these values, the code can appear daunting. Luckily there’s a quick and simple way to make UIAppearance code easier to read (and write!).
UISS, developed by Robert Wijas, is an iOS library build on top of UIAppearance that provides a convenient way to define styles using JSON.
Let’s look at a more complex example of styles defined in Objective-C using UIAppearance:
The UISS code is not only easier to read, but also more pleasurable to write!
UISS includes logging and a console for troubleshooting style problems. It can even generate the equivalent UIAppearance code from the JSON files, which is handy if you want to see exactly what’s going on.
Styles can even be loaded from a remote server to enable live style updates in your app.
I was able to get up and running with UISS quickly and found it greatly improved the readability of my UIAppearance definitions. UISS is available on GitHub or as a Cocoapod.