在我的应用程序中,我设法使用 uibezierpath 画一条线并将其添加到 View 的子层中,在我设法对此 View 应用一些转换后,借助 UIRotationGestureRecognizer 和 UIPinchGestureRecognizer 旋转 View 并更改大小。 问题是,当我使用 UIPinchGestureRecognizer 更改 View 的大小时,线条的粗细也发生了变化,并且我无法保持相同的粗细。
实际上,我尝试做的是绘制一个箭头并能够移动它、旋转它并调整它的大小。 我设法做到了这一点,但是当我捏住 View 时,箭头的粗细发生了变化:)
有可能避免这种情况吗?
谢谢:)
最佳答案
swift 4:
let path = UIBezierPath()
path.move(to: CGPoint(x: 100, y: 100))
path.addLine(to: CGPoint(x: 150, y: 150))
path.stroke()
let traingle = CAShapeLayer()
traingle.path = path.cgPath
traingle.fillColor = UIColor.gray.cgColor
traingle.setAffineTransform(CGAffineTransform(rotationAngle: .pi))
self.view.layer.addSublayer(triangle)
关于ios - 快速转换使用 uibezierpath 创建的线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40001037/