ios – 自定义UIButton圆角在亮点上变得平方?

前端之家收集整理的这篇文章主要介绍了ios – 自定义UIButton圆角在亮点上变得平方?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个自定义UIButton的以下代码

btnLogin.layer.cornerRadius = 10;

[btnLogin setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"bluetint.png"]]];
[btnLogin setAlpha:1];
[btnLogin setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[btnLogin setBackgroundImage:[UIImage imageNamed:@"reallybluetint.png"] forState:UIControlStateHighlighted];
[btnLogin setBackgroundImage:[UIImage imageNamed:@"reallybluetint.png"] forState:UIControlStateSelected];

当我突出显示按钮时,即使它在正常状态下有圆角,它也会变成平方.

有任何想法吗?

解决方法

尝试使用此代码,它将工作,

btnLogin.layer.cornerRadius = 10.0;
[btnLogin setClipsToBounds:YES];

猜你在找的Xcode相关文章