【发布时间】:2017-12-09 19:13:37
【问题描述】:
我正在尝试实现一个可以使用 UIBezierPath 笔划在 Swift 4 中更改位置的光标。目前,我有一个函数,它有一个参数位置,其中包含“光标”的新 x 和 y 位置。我想将此位置参数用作 UIView 中光标的新位置。每次调用该函数时,我当前的实现都会呈现另一个光标。有没有办法改变 UIBezierPath 的一个实例的位置?请参阅下面的示例代码以供参考。
private var cursor:UIBezierPath = UIBezierPath()
public func changeCursorLocation(location: ScreenCoordinates) {
self.cursor = UIBezierPath()
UIColor.black.setStroke()
self.cursor.lineWidth = 2
self.cursor.move(to: CGPoint(x: location.x, y: location.y))
self.cursor.addLine(to: CGPoint(x: location.x + 100, y: location.y)) // change if staff space changes
self.cursor.stroke()
}
【问题讨论】:
标签: ios swift ipad core-graphics swift4