ios - 按钮外观点击版本

标签 ios uibutton

我希望按钮看起来像是某种方式,而不是将按钮子类化,而是这样编写的

[[UIButton appearanceWhenContainedIn:[EABaseViewController class], nil]setBackgroundImage:[UIImage imageNamed:@"gradient_border"] forState:UIControlStateNormal];
[[UIButton appearanceWhenContainedIn:[EABaseViewController class], nil]setBackgroundImage:[UIImage imageNamed:@"gradient_border_grey"] forState:UIControlStateHighlighted];
[[UIButton appearanceWhenContainedIn:[EABaseViewController class], nil]setBackgroundImage:[UIImage imageNamed:@"gradient_border_grey"] forState:UIControlStateSelected];
  [[UIButton appearanceWhenContainedIn:[EABaseViewController class], nil]setBackgroundImage:[UIImage imageNamed:@"gradient_border_grey"] forState:UIControlStateSelected|UIControlStateHighlighted];
[[UIButton appearanceWhenContainedIn:[EABaseViewController class], nil]setBackgroundImage:[UIImage imageNamed:@"grey_border_grey"] forState:UIControlStateDisabled];

问题是,当我单击按钮时,而不是更改为图像gradient_border_grey,而是更改了其alpha。我找不到解决方法?

我如何解决它 ?

最佳答案

我需要将按钮类型设置为自定义以解决此问题

关于ios - 按钮外观点击版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26201994/

相关文章:

ios - UITextFieldDelegate 和整行删除

ios - 将数据从自定义单元格(在 ViewController 上的表中)传递到 uiviewcontroller 本身 Swift 3 iOS

ios - Swift - 设置 UIButton 标题而不考虑状态

swift - 如何使 UIButton 具有正确的图像和文本外观?

iOS 6 和 iOS 7 UIButton 标签垂直对齐

swift - 将 UIVisualEffectView 添加到按钮

ios - 以编程方式添加自定义按钮相互混淆

ios - Apple 的应用程序加载器未上传。卡住和重置

ios - 无法通过试飞安装应用。此请求有一个错误

ios - 以编程方式创建的 UITableView 中单元格的响应能力