我使用下面的代码使应用程序中的所有按钮具有相同的颜色。但是 UITTableView 行中的附件图标也有它。有没有办法在表格 View 中忽略它?
[[UIButton appearance] setBackgroundColor:[UIColor purpleColor]];
最佳答案
UIView
符合UIAppearanceContainer
协议(protocol)。
因此,您应该使用 appearanceWhenContainedIn:
来区分按钮,具体取决于按钮所在的位置。
[[UIButton appearance] setBackgroundColor:[UIColor purpleColor]];
[[UIButton appearanceWhenContainedIn:[UITableView class], nil] setBackgroundColor:nil];
最好使用 UITableViewCell
子类而不是 TableView 。
关于ios - 全局设置按钮的背景颜色,UITableView 中的辅助按钮除外,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20916996/