当我设置按钮的alpha时,它也会影响标题的不透明度。有没有办法只针对背景,而将标题alpha保留为1.0?
发布于 2016-04-21 18:24:51
您还可以更改情节提要中颜色的alpha。
请参阅附图:

发布于 2013-07-06 00:01:42
继承UIButton并扩展setEnabled:方法似乎是可行的:
- (void) setEnabled:(BOOL)enabled {
[super setEnabled:enabled];
if (enabled) {
self.imageView.alpha = 1;
} else {
self.imageView.alpha = .25;
}
}发布于 2013-07-06 00:04:15
使用UIButton,可以通过将按钮样式设置为“自定义”而不是“圆角矩形”来删除背景。这保持了标题不变,但删除了按钮背景。如果在故事板中执行此操作,则可以在元素属性中更改按钮样式。对于代码,格式为:
UIButton *button = [[UIButton alloc] buttonWithType:UIButtonTypeCustom];
// Setup frame and add to viewhttps://stackoverflow.com/questions/17492840
复制相似问题