https://www.coder.work/article/785950
我用 UIBeizerPath 画了一条垂直线,我需要这条线的角半径值为 5。我试图记忆起 [pathLayer setCornerRadius: 5];
但我没有得到结果... 你能帮助我吗?如何分配角半径值?这是我使用的代码
// crea le barre del grafico e gli assegna l'altezza della label y corrispondente
UIBezierPath *path = [UIBezierPath bezierPath];
[path moveToPoint:CGPointMake(xPaddingFromYAxis +spaceBetweenBar *j, 200)];
[path addLineToPoint:CGPointMake(xPaddingFromYAxis +spaceBetweenBar *j, yLabelValue.center.y )];
CAShapeLayer *pathLayer = [CAShapeLayer layer];
pathLayer.frame = self.bounds;
pathLayer.path = path.CGPath;
pathLayer.strokeColor = [UIColor darkGrayColor].CGColor;
pathLayer.fillColor = nil;
pathLayer.lineWidth = 50;
[pathLayer setCornerRadius:5];
pathLayer.masksToBounds = NO;
[scroll.layer addSublayer:pathLayer];
最佳答案
您需要将掩码绑定(bind)设置为"is"。 pathLayer.masksToBounds = YES;
试试看:
UIBezierPath *path = [UIBezierPath bezierPath];
[path moveToPoint:CGPointMake(xPaddingFromYAxis +spaceBetweenBar *j, 200)];
[path addLineToPoint:CGPointMake(xPaddingFromYAxis +spaceBetweenBar *j, yLabelValue.center.y )];
CAShapeLayer *pathLayer = [CAShapeLayer layer];
pathLayer.frame = self.bounds;
pathLayer.path = path.CGPath;
pathLayer.strokeColor = [UIColor darkGrayColor].CGColor;
pathLayer.fillColor = nil;
pathLayer.lineWidth = 50;
[pathLayer setCornerRadius:5];
pathLayer.masksToBounds = YES;
[scroll.layer addSublayer:pathLayer];
关于ios - 如何使用 CAShaperLayer 设置圆角半径值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46565095/
标签:pathLayer,圆角,CAShapeLayer,CGPointMake,ios,layer,CAShaperLayer,path,spaceBetweenB From: https://www.cnblogs.com/itlover2013/p/17143379.html