2014-10-01 45 views
0

我使用的是内部的UIView drawRect下面的代码来绘制矩形圆角:UIBezierPath使得角落大胆

CGContextRef context = UIGraphicsGetCurrentContext(); 

UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:rect cornerRadius:5]; 

CGContextSetFillColorWithColor(context, _fillColor.CGColor); 
[path fill]; 

CGContextSetLineWidth(context, 1); 
CGContextSetStrokeColorWithColor(context, _strikeColor.CGColor); 
[path stroke]; 

出于某种原因,我的行程越来越假象:大胆的角落。

enter image description here

看起来并不好。我也试图为中风建立独立的路径 - 同样的问题。

+1

屏幕截图,也许...? – holex 2014-10-01 11:43:00

+0

@holex对不起,附上一个 – 2014-10-01 11:47:54

+0

尝试用rect = CGRectInset(self.bounds,0.5,0.5) – Krzysztof 2014-10-01 11:50:00

回答

0

认为角落是正确的,但中风不在视野内。请尝试:

rect = CGRectInset(self.bounds, 0.5, 0.5) 

创建路径之前。

0
//// Rectangle Drawing 
UIBezierPath* rectanglePath = [UIBezierPath bezierPathWithRoundedRect: CGRectMake(57, 48, 136, 31) byRoundingCorners: UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii: CGSizeMake(5, 5)]; 
[rectanglePath closePath]; 
[UIColor.grayColor setFill]; 
[rectanglePath fill];