How to change the color of the title in TTLauncherItem?

走远了吗. 提交于 2019-12-12 07:38:15

问题


I am having a lot of trouble trying to change the color in the TTLauncherItem, because the default gray color does no work with my background.

Any ideas?


回答1:


Here's what I used to change the text color of TTLauncherItem from the default gray color to black (looks better on a white background):

(1) Create a Stylesheet that inherits from TTDefaultStyleSheet:

Stylesheet.h:

@interface StyleSheet : TTDefaultStyleSheet {}   
@end

Stylesheet.m:

// Style for TTLauncherItems
- (TTStyle*)launcherButton:(UIControlState)state {
    return 
    [TTPartStyle styleWithName: @"image" 
                         style: TTSTYLESTATE(launcherButtonImage:, state) 
                          next: [TTTextStyle 
                                 styleWithFont:[UIFont boldSystemFontOfSize:11]
                                 color: RGBCOLOR(0, 0, 0)
                                 minimumFontSize: 11 
                                 shadowColor: nil
                                 shadowOffset: CGSizeZero 
                                 next: nil]];
}

(2) In AppDelegate.m, initialize the Stylesheet:

[TTStyleSheet setGlobalStyleSheet:[[[StyleSheet alloc] init] autorelease]];

That's it ... in the Stylesheet, change the UIFont and RGBCOLOR(0, 0, 0) to suit your requirements.




回答2:


You can find the answer here: http://groups.google.com/group/three20/browse_thread/thread/552d453dea748645

Basically you need to set a TTStyleSheet and perform all you customizations there.



来源:https://stackoverflow.com/questions/3770467/how-to-change-the-color-of-the-title-in-ttlauncheritem

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!