Tuesday, 26 February 2013

Design UILabel in optimize way for large project

It is really hard to find out any iOS application without UILabel.
Here,I am trying to explain how to design UILabel in a optimize way that really helpful in large scale project.You will get benefit of this article when you need to change any attribute of all UILabel in your project.

For practical usage, Lets assume you project consist 100 UILabel as follows.

At the end of your project you thought UILabel color would be better if its text color red.As normal sense, you will go to your inspector from xcode and change the color red 100 times.Thats really worse for a Developer.To solve this problem we can use a common class that Inherit form a UILabel and the common design we will implement here.

First, create a class and select "Sub class of UILabel". I gave this class name DesignFontStyle.

At DesignFontStyle.h and DesignFontStyle.m coded as follows

Now, Select each label and change its class with the new class that we created (DesignFontStyle.h).
At present it consist UILabel.

Do it for the all Label.

Now if you need to change all the color of your label to RED just access the DesignFontStyle.m class and change the color  [UIColor redColor]. thats it.

Quite simple to edit.

By the way, we can create more font design class as we want based on types of design label in whole project.

Hope it will help you to develop your nice Application.

No comments:

Post a Comment