更改TTButton的色调颜色
问题描述:
现在在我的应用程序中,我有一个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更改颜色。 以后有什么方法可以改变色调颜色吗?
答
更改按钮的tintColor将非常困难。因为还有其他颜色来源于色调颜色,并在风格的不同部分以及所有状态中使用。
如果您只有有限数量的浅色使用,最有前途的方法是使用TTButons setStylesWithSelector:
方法更改样式。只需将它传递给样式表中定义的方法的选择器即可。
如果您必须支持任意颜色,您甚至可以在样式表上使用可设置的UIColor属性,然后使用该属性构建按钮的样式。我不确定,但这可能会受到TTStylesheet缓存样式的限制。