开发者

How to apply Style sheet to label/textfield in iPhone?

I have lots of labels in my application. Is there any way 开发者_JAVA百科to apply common style sheet to all label rather than giving style to individual label?


you can write a stylesheet class if you use THree20 Library by overriding TTDefaultStyleSheet.

But if your need is minmal,try with custom class with styles written & reference those to UILabel's

Like

constants.h

#define COLOR_VALUE  [UIColor colorWithRed:0.5f green:0.5f blue:0.5f alpha:0.5f]

then in your file call lblName.textColor = COLOR_VALUE

But not sure you can write all styles using this method!


Create simple UIFont and UIColor categories in your application, and provide semantic descriptions of the data you want to style. Or make “CASCADING STYLE” classes.

This article will explain how: http://akosma.com/2010/06/03/objective-c-categories-as-stylesheets/


You cannot apply 'style sheet' to your native app UI. You can subclass a UILabel. Style it as you want (although there isn't much you can change other than font, color and background image) and use the custom label objects instead of default UILabel...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜