Ios 全局设置按钮的背景色,UITableView中的附件按钮除外
我使用下面的代码使应用程序中的所有按钮颜色相同。但是,UITableView行中的附件图标也具有此功能。有没有办法在表视图中忽略它Ios 全局设置按钮的背景色,UITableView中的附件按钮除外,ios,objective-c,uiappearance,Ios,Objective C,Uiappearance,我使用下面的代码使应用程序中的所有按钮颜色相同。但是,UITableView行中的附件图标也具有此功能。有没有办法在表视图中忽略它 [[UIButton appearance] setBackgroundColor:[UIColor purpleColor]]; UIView符合UIAppearanceContainer协议 因此,您应该使用appearancewhen contained in:来区分不同的按钮,具体取决于它们所包含的位置 [[UIButton appearance] set
[[UIButton appearance] setBackgroundColor:[UIColor purpleColor]];
UIView
符合UIAppearanceContainer
协议
因此,您应该使用appearancewhen contained in:
来区分不同的按钮,具体取决于它们所包含的位置
[[UIButton appearance] setBackgroundColor:[UIColor purpleColor]];
[[UIButton appearanceWhenContainedIn:[UITableView class], nil] setBackgroundColor:nil];
最好使用UITableViewCell
子类而不是表视图。您可以使用
[[UIButton appearanceWhenContainedIn: [UITableView class]] setBackgroundColor:[UIColor differentColor]];
这是可行的,但它是
[[UITableViewCell类中包含的UIButton外观],nil]setBackgroundColor:nil]代码>@MikeFlynn啊,对了,更正了答案。对不起,我正在我的Windows计算机上打字。