Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom UIButton rounder corners become squared on highlight?

Tags:

xcode

button

ios

I have the following code for a custom 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];

When I highlight the button it becomes squared even though it has rounded corners in the Normal state.

Any ideas?

like image 400
Darko Avatar asked Mar 25 '23 06:03

Darko


1 Answers

Try with this code it will work,

btnLogin.layer.cornerRadius = 10.0;
[btnLogin setClipsToBounds:YES];
like image 65
Balu Avatar answered Apr 25 '23 10:04

Balu