我有自定义 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];

关于ios - 自定义 UIButton 圆角在突出显示时变成方形?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/16116602/

10-08 20:51