使用一段以下列方式获取CGPath的代码:
let dirX = -spread
let rect = bounds.insetBy(dx: dirX, dy: dirX)
let cgPath = UIBezierPath(rect: rect).cgPath有什么方法可以直接使用rect来获得CGPath吗?
我知道有
CGPath(rect: CGRect, transform: UnsafePointer<CGAffineTransform>)但是我不确定直接用init获取相同的CGPath是否简单,因为我不知道如何使用UnsafePointer。
欢迎解释和例子。
发布于 2018-04-27 06:11:18
您可以使用CGPath(rect: CGRect, transform: UnsafePointer<CGAffineTransform>?)并以可选的方式在CGAffineTransform中传递nil。
let dirX = -spread
let rect = bounds.insetBy(dx: dirX, dy: dirX)
let cgPath = CGPath(rect: rect, transform: nil)但是这不会对应用程序的功能产生任何影响,即使是在代码数量上,因为无论如何都是一行。
https://stackoverflow.com/questions/50056157
复制相似问题