小编h99*_*999的帖子

CAShapeLayer的框架和界限

我在工作CAShapeLayer.而企图拉拢非线性path.I要设置框架CAShapeLayer.所以我可以使用CGPathGetPathBoundingBox的方法从得到的帧CGPathRef.

这是代码:

CGMutablePathRef path = CGPathCreateMutable();
CGPathAddArc(path, NULL, rect.size.width/2, rect.size.height/2, 100, (0), (M_PI_2), NO);
CGPathAddArc(path, NULL, rect.size.width/2, rect.size.height/2, 100-50, (M_PI_2), (0), YES);
CGPathCloseSubpath(path);
CAShapeLayer* arcLayer = [[CAShapeLayer alloc]init];
arcLayer.path = path;
arcLayer.frame = CGPathGetPathBoundingBox(path);
arcLayer.bounds = CGPathGetPathBoundingBox(path);
[self.layer addSublayer:arcLayer]; ` 
Run Code Online (Sandbox Code Playgroud)

请参考我的代码仔细.我已设置相同的框架和范围,以CAShapeLayer.My问题是,如果我没有设置界限(同帧),那么它不会显示我的内容或它不会显示内frame.Why我的内容?请帮助我.谢谢你.

cashapelayer cgpath ios

11
推荐指数
2
解决办法
1万
查看次数

带角度的CAGradientLayer

我画CGPath的不是矩形或正方形,而是添加CGPathCAShapeLayer.这CAShapeLayer是从CGPath使用中获得的框架CGPathGetBoundingBox(path).所以它将是矩形或方形.现在我想将渐变颜色设置为图层,但我的路径不是矩形或正方形,因此它不会在整体上均匀地传播渐变颜色CGPath.有没有办法将渐变颜色设置为CGPath或如何设置渐变颜色与角度?

请参考截图了解情况.这里白色表示框架CGPath和绿色,这是我们绘制的CGPath.在底部CGPath你可以看到不均匀分布的白色渐变色CGPath.

在此输入图像描述

在此输入图像描述

cashapelayer ios cagradientlayer

3
推荐指数
1
解决办法
2711
查看次数

标签 统计

cashapelayer ×2

ios ×2

cagradientlayer ×1

cgpath ×1