2010-07-09 83 views
0

現在在我的應用程序中,我有一個TTButton。 我設置TTButton的顏色最初使用樣式表,如TTCatalog更改TTButton的色調顏色

它看起來像這樣:

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

然後有一個叫buttonStyleSheet類,並在那裏我有:

- (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]; 
} 

但事實是,只有我初始化,着色顏色將在(TTStyle*)toolbarBackButton:(UIControlState)state方法中設置該顏色。

但我希望能夠在以後使用setter更改顏色。 以後有什麼方法可以改變色調顏色嗎?

回答

1

更改按鈕的tintColor將非常困難。因爲還有其他顏色來源於色調顏色,並在風格的不同部分以及所有狀態中使用。

如果您只有有限數量的淺色使用,最有前途的方法是使用TTButons setStylesWithSelector:方法更改樣式。只需將它傳遞給樣式表中定義的方法的選擇器即可。

如果您必須支持任意顏色,您甚至可以在樣式表上使用可設置的UIColor屬性,然後使用該屬性構建按鈕的樣式。我不確定,但這可能會受到TTStylesheet緩存樣式的限制。