SmallChess
SmallChess

Reputation: 8116

Change the edge color for UIButton in iOS 6.0

For some reason, iOS 6 draws a standard RoundedRect differently. The old rounded button (top) has black as the edge when selected or highlighted. The same code draws the button with white as the edge in iOS 6.0 (below). I can't find a way to change the color back to Black as in iOS 5. Any idea?

The code is simply

_loadButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[_loadButton setFrame:CGRectMake(200, 130, 115, 40)];
[_loadButton setTitle:@"Load Game" forState:UIControlStateNormal];

enter image description here

enter image description here

Upvotes: 0

Views: 1516

Answers (1)

Stas
Stas

Reputation: 9935

Try this:

[button.layer setBorderColor:(__bridge CGColorRef)([UIColor blackColor])];

For rounded edges:

button.layer.cornerRadius = 8;

You can also add this:

[button.layer setMasksToBounds:YES];
[button.layer setBorderWidth:1.0f];

Upvotes: 3

Related Questions