【发布时间】:2018-01-31 00:52:30
【问题描述】:
我在情节提要中使用约束设置了UIView,我想使用带有UIBezierPath 的CAShapeLayer 向此视图添加一个圆形进度。
我已正确添加此内容,但圆圈并未扩展到所有视图。我在我的 viewDidLoad 函数中调用它。我的视图对调整 top-x 视图的高度和宽度有限制。
- (void)viewDidLoad {
[super viewDidLoad];
CAShapeLayer *borderLayer = [CAShapeLayer layer];
borderLayer.fillColor = [UIColor whiteColor].CGColor;
CGFloat lineWidth = 4;
CGRect rect = CGRectMake(lineWidth+lineWidth/2, lineWidth+lineWidth/2, self.myView.bounds.size.width/2, self.myView.bounds.size.height/2);
borderLayer.path = [UIBezierPath bezierPathWithOvalInRect:rect].CGPath;
borderLayer.strokeColor = [[UIColor redColor] CGColor];
borderLayer.lineWidth = lineWidth;
[borderLayer setFillColor:[UIColor clearColor].CGColor];
[self.myView.layer addSublayer:borderLayer];
}
圆圈进度未调整为UIView,显示如下:
我怎样才能把这个占据整个UIView 画成这样:
【问题讨论】:
标签: ios objective-c uiview uibezierpath cashapelayer