【发布时间】:2017-02-07 13:52:37
【问题描述】:
我正在使用 swift 2.2,我正在处理这样的问题: 我有一组 UIBezier 对象,我需要为它们创建一个笔触作为一条路径。
我曾经有一个特殊的功能,但这种方法的优点是它创建了几个层。 这符合我的要求,因为我需要一层
func createStroke(line: UIBezierPath) {
self.currentPath = CAShapeLayer()
currentPath.path = line.CGPath
currentPath.strokeColor = UIColor.blackColor().CGColor
currentPath.fillColor = UIColor.clearColor().CGColor
currentPath.lineWidth = 1
self.view.layer.addSublayer(currentPath)
}
从我的贝塞尔线数组创建多路径的最佳方法是什么?第一个想法是创建一个for-loop循环,但我认为这不是一种干净的方式。
【问题讨论】:
-
您可以通过附加所有贝塞尔路径来创建单个路径,然后将结果设置为 CAShapeLayer 路径。更多信息:developer.apple.com/reference/uikit/uibezierpath/1624377-append
标签: arrays swift uibezierpath cashapelayer bezier