3
OK、UIBezierPathsの新機能ですが、ユーザーの指の位置に応じてエンドポイントが更新されるパスが必要です。それはtouchesMoved
Swift UIView:人の指の終わりに常にパスを作成しますか?
に変更する必要がありますこれまでのところ私が持っている:
func customInit() {
print("init scene")
self.backgroundColor = UIColor.cyan
path.move(to: CGPoint(x: 0, y: 0))
path.addLine(to: CGPoint(x: 300, y: 300))
let shapeLayer = CAShapeLayer()
shapeLayer.path = path.cgPath
shapeLayer.strokeColor = UIColor.blue.cgColor
shapeLayer.lineWidth = 3.0
self.layer.addSublayer(shapeLayer)
}
override public func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
var touch : UITouch! = touches.first! as UITouch
var location = touch.location(in: self)
path.move(to: location)
}
は、私は、これは、パスのエンドポイントを更新するだろうと思ったが、何も、元の線を引く超え起こりません。私はこれにSKSceneを使用したくないですが、何がうまくいかないのか分かりません。
どのようにすれば、いつでもユーザーのタップの位置にポイントを置くことができますか?
ありがとうございます!偉大な説明 – skyguy
私は質問があります - 私はそれが何もない(開始点と終了点が同じ点です)私はそれを私の指を離すと元に戻すでしょうか? – skyguy
@skyguy上記の私の更新を参照してください。 – nathan