我在堆栈溢出时发现了这段代码。
CGMutablePathRef path = CGPathCreateMutable()
CGPathMoveToPoint(path, nil, 0, -(self.tileSize.height / 2))
CGPathAddLineToPoint(path, nil, (self.tileSize.width / 2), 0)
CGPathAddLineToPoint(path, nil, 0, (self.tileSize.height / 2))
CGPathAddLineToPoint(path, nil, -(self.tileSize.width / 2), 0)
CGPathCloseSubpath(path)
它是答案的一部分,代码应该创建一个具有等距瓷砖形状但不起作用的路径。所以有人知道为什么以及如何创建这个mutablePath? 谢谢。
答案 0 :(得分:1)
如果您的问题是代码无法编译,您只需将其从Objective-C转换为Swift
let path = CGPathCreateMutable()
CGPathMoveToPoint(path, nil, 0, -(self.tileSize.height / 2))
CGPathAddLineToPoint(path, nil, (self.tileSize.width / 2), 0)
CGPathAddLineToPoint(path, nil, 0, (self.tileSize.height / 2))
CGPathAddLineToPoint(path, nil, -(self.tileSize.width / 2), 0)
CGPathCloseSubpath(path)