自定义按钮框架看起来不如Round Rect UIButton

Nik*_*ozi 10 custom-controls uibutton ios uibezierpath

我正在尝试绘制自定义按钮框架,如下所示:

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

[stroke stroke];
Run Code Online (Sandbox Code Playgroud)

但由于某种原因,角落曲线看起来比侧面更有思想性.如果你看看UIButton的默认框架,它是非常统一的.A是UIButton,B是自定义按钮.

任何想法我怎么能使它更像UIButton.

A是UIButton,B是自定义按钮

jrt*_*ton 25

你正在抚摸按钮的界限.这将绘制您的线在视图边缘的中心,因此线的一半厚度超出边界并且不绘制.这就是它在角落里的全厚度的原因.CGRectInset在你的边界矩形上使用(插入一半厚度的线条)并按下直线.