Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom Button frame doesn't look as good as Round Rect UIButton

I'm trying to draw a custom button frame as follows:

UIBezierPath *stroke = [UIBezierPath bezierPathWithRoundedRect:self.bounds
                                                  cornerRadius:RECT_CORNECR_RADIUS];

[stroke stroke];

But for some reason the corner curves look thinker than the sides. If you look at the UIButton's default frame it's very uniform. A is a UIButton, B is a custom button.

Any ideas how I can make it more like the UIButton.

A is a UIButton, B is a custom button

like image 720
Nikolozi Avatar asked Oct 27 '11 07:10

Nikolozi


1 Answers

You are stroking the bounds of your button. This will draw your line centred over the edge the view, so half of the thickness of the line is outside the bounds and is not drawn. This is why it is full thickness in the corners. Use CGRectInset on your bounds rectangle (inset by half the thickness of your line) and stroke THAT rect.

like image 62
jrturton Avatar answered Sep 21 '22 01:09

jrturton