Pet*_*dil 11 objective-c rounded-corners ios uibezierpath
我无法在使用UIBezierPath创建的Arc上显示圆角.无论我是否设置kCGLineCapRound,它仍然是完美的平方.
此主题应该是一样的这一个,但是解决方案是行不通的.
这是我在viewWillAppear中的示例代码(仅用于测试目的):
int radius = 100;
CAShapeLayer *arc = [CAShapeLayer layer];
UIBezierPath *path = [UIBezierPath bezierPathWithArcCenter:CGPointMake(100, 50) radius:radius startAngle:M_PI endAngle:M_PI/150 clockwise:YES];
path.lineCapStyle = kCGLineCapRound;
arc.path = path.CGPath;
arc.position = CGPointMake(CGRectGetMidX(self.view.frame)-radius, CGRectGetMidY(self.view.frame)-radius);
arc.fillColor = [UIColor clearColor].CGColor;
arc.strokeColor = [UIColor purpleColor].CGColor;
arc.lineWidth = 10.0f;
arc.cornerRadius = 3.0f;
Run Code Online (Sandbox Code Playgroud)
以下是它的外观:

我很无奈,所以我会感激任何帮助.多谢你们.
Rob*_*Rob 33
使用而不是路径的lineCap属性.CAShapeLayerlineCapStyle
arc.lineCap = kCALineCapRound;
Run Code Online (Sandbox Code Playgroud)
如果您正在调用路径的stroke方法(例如,如果您正在执行此drawRect操作或手动绘制a UIGraphicsContext),则设置属性,如cap或join样式UIBezierPath.但在使用时CAShapeLayer,属性设置在形状图层上,而不是路径上.
| 归档时间: |
|
| 查看次数: |
4340 次 |
| 最近记录: |