views:

49

answers:

1

Hey guys. Right now in my application, I have a TTButton. I am setting the color of the TTButton initially using stylesheet like TTCatalog. it's like

[TTStyleSheet setGlobalStyleSheet:[[[CustomBadgeButtonStyleSheet alloc] init] autorelease]];
[code for initializing ttbutton here];

And then there is a class called buttonStyleSheet in there I have

- (TTStyle*)toolbarBackButton:(UIControlState)state {

TTShape* shape = [TTRoundedLeftArrowShape shapeWithRadius:4.5]; UIColor* tintColor = RGBCOLOR(47,47,47); return [TTSTYLESHEET toolbarButtonForState:state shape:shape tintColor:tintColor font:nil]; }

But the thing is that only I initialize it, the tint color will be that color set in - (TTStyle*)toolbarBackButton:(UIControlState)state { method.

But I want to be able to change the color later using setter. Is there a way that I can change the tint color later?

A: 

Changing the tintColor of the button would be very difficult. Because there are other colors derived from the tint color and used in different parts of the style and for all states.

If you have only a limited number of tint colors to use, the most promising approach would be to use TTButons setStylesWithSelector: method to change the style. Simply pass it the selector of the method you defined in your stylesheet.

If you have to support arbitrary colors, you can even use a settable UIColor property on your stylesheet, which is then used to construct a style for your button. I'm not sure, but this could restricted by TTStylesheet caching styles.

tonklon