Why you should be using UIAppearance class in your code

Lets consider this example, you need to customize your navigation bar, for text color, tint color and fonts.
If you aren’t using UIAppearance, you would either do one of the following :

  • subclass navigation bar/controller, set the changes in this class.
  • change the settings every time you use the navigation controller.

Now, lets consider if your using UIAppearance, in your code, you would do the following:
Basically in the above code snippet, I am changing the navigation bar color, everytime it appears in the controller. Ideally, you can place this in your main controller class, so that its initialized when the app starts up, or in the delegate class. This will help you reduce the redundant code in your project.


Leave a Reply

Your email address will not be published. Required fields are marked *