CAShapeLayer中的多个路径 [英] Multiple paths in CAShapeLayer
本文介绍了CAShapeLayer中的多个路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道是否有可能让CAShapeLayer描边超过一条路径,因为它实际上只需要一条路径作为参数:
I was wondering if it is somehow possible to let a CAShapeLayer stroke more than only one path since actually it only takes one path as parameter like:
CAShapeLayer* myLayer=[CAShapeLayer layer];
myLayer.path=myBezierPath
但是如果我想要描边多条路径怎么办?到那层?
But what if I would like to stroke more than one path onto that layer?
推荐答案
使用
void CGPathAddPath (
CGMutablePathRef path1, // The mutable path to change.
const CGAffineTransform *m, // A pointer to an affine transformation matrix, or NULL if no transformation is needed. If specified, Quartz applies the transformation to path2 before it is added to path1.
CGPathRef path2 // The path to add.
);
代码示例:
CGMutablePathRef combinedPath = CGPathCreateMutableCopy(path.CGPath);
CGPathAddPath(combinedPath, NULL, path2.CGPath);
CGPathAddPath(combinedPath, NULL, path3.CGPath);
CGPathAddPath(combinedPath, NULL, path4.CGPath);
myLayer.path = combinedPath;
这篇关于CAShapeLayer中的多个路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文