I want to create a Category suppose of UILabel so using which for every device we can change the font size of text as need
Asked
Active
Viewed 339 times
2
-
possible duplicate of http://stackoverflow.com/questions/11907761/how-to-set-a-custom-font-for-entire-ios-app-without-specifying-size – KrishnaCA Feb 17 '17 at 10:09
-
KrishnaCA i want to create a class which will support all the element that using UIFont class – Ahmed Sahib Feb 17 '17 at 10:21
-
So, you want a custom `UILabel` with a specific `UIFont` right – KrishnaCA Feb 17 '17 at 10:25
-
the class will be use for all the element which uses UIFont class like textfield,textview,label etc.. – Ahmed Sahib Feb 17 '17 at 11:34
1 Answers
1
You can create a category class , and add a method like :
+(UIFont *)fontWithName:(NSString *)fontName {
CGFloat fontSize = 14.0;
if (IS_IPHONE6) {
fontSize = 15.0;
}
if (IS_IPHONE6P) {
fontSize = 16.0;
}
return [UIFont fontWithName:fontName size:fontSize];
}
About device's size: iphone6 = iphone7 & 6plus = 7plus.

lostInTransit
- 70,519
- 61
- 198
- 274

AngelSunpx
- 11
- 1
-
ya but to change the font of label i have to call every object of UIlabel using i have created but i don't want to do – Ahmed Sahib Feb 17 '17 at 09:30
-
oh I see, you need a global method like a define to control the size, if I have time out of work, I will test some. – AngelSunpx Feb 20 '17 at 10:27