tags:

views:

872

answers:

1

I'm using TTTabStrip in my iPhone app, the screenshot is below

http://i377.photobucket.com/albums/oo217/zhustar/tttabbar.png?t=1265213089

I want to change the background color of the TTTabItem selected from blue to green
and change the color of font from white to black.
How can I do that ?

+1  A: 

The way the TTTabItem is styled visually takes advantage of the TTStyleSheet mechanisms implemented throughout the Three20 library. I had to do this for my own project, and I found the simplest way was to subclass TTDefaultStyleSheet and override the particular methods that relate to styling the tab items and the tab bars.

The basic idea is to subclass TTDefaultStyleSheet and override the methods you want to change. I don't remember exactly which methods they are, but they're along the lines of tabBarItem and tabBarTintColor etc. You can look at the source of TTDefaultStyleSheet to see which methods you need, and what their default implementations look like.

Once you've done this, you need to set your stylesheet as the global stylesheet, like this

[TTStyleSheet setGlobalStyleSheet:myStyleSheetInstance];

That should then allow you set your own styles for the tab items etc.

For more info on Three20 and how to use the Style system, look at http://three20.info

Jasarien