我正在尝试为我的应用中的所有UIButton设置样式,但是当我设置ClipsToBounds时会出错。
非法属性类型,c表示外观设置器,_installAppearanceSwizzlesForSetter
我将此代码放在app delegate中的didFinishLaunchingWithOptions中。
[[UIButton appearance] setBackgroundColor:[UIColor colorWithRed:0.314 green:0.745 blue:0.62 alpha:1]];
[[UIButton appearance] setTintColor:[UIColor whiteColor]];
[UIButton appearance].layer.cornerRadius = 10;
[[UIButton appearance] setClipsToBounds:YES];
我想让角落四舍五入。
答案 0 :(得分:0)
我尝试了[UIButton appearance].clipsToBounds = YES;
并且没有崩溃。 clipsToBounds
是property
,而不是method
,但您将其称为方法,也许这就是问题所在。
答案 1 :(得分:-2)
设置所有按钮样式的更好方法是为某个范围内的所有按钮指定标签并添加以下代码:
for (int i=20; i<lastButtonTag; i++)
{
UIButton* button = (UIButton*) [self viewWithTag:i];
// add more styling here
button.layer.cornerRadius = 10;
button.clipsToBounds = YES;
}