在Disabale UIButton上 [英] on Disabale UIButton
本文介绍了在Disabale UIButton上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当禁用按钮时.不透明度降低到50%.是否有任何方法可以将不透明度降低到25%
when disable button. opacity reduced to 50% .is there any way to reduce opacity to 25%
推荐答案
我将UIButton子类化,并将setEnabled:方法重写为类似这样的内容:
I would subclass UIButton and override the setEnabled: method to something like this:
- (void) setEnabled:(BOOL)enabled {
NSLog(@"Button enabled = %d", enabled);
[super setEnabled:enabled];
UIColor *color = self.backgroundColor;
if (!self.isEnabled) {
self.backgroundColor = [color colorWithAlphaComponent:0.75];
} else {
self.backgroundColor = [color colorWithAlphaComponent:1.0];
}
}
这篇关于在Disabale UIButton上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文