Что если нам нужно добавить замедление к вращению? Как мы можем сделать это ?

дал UIGestureRecognizer, чтобы вращать вид одним пальцем.

Вид вращается в начале, но как только он достигает определенной степени, вращение поворачивается в другом направлении.

Можете ли вы помочь мне с моим кодом?

UIViewController <- Здесь все хорошо

override func viewDidLoad() {
    super.viewDidLoad()

    // Do any additional setup after loading the view.

    let wheel = TestWheelView()
    wheel.frame = CGRect.init(x: self.view.center.x - 120, y: self.view.center.y - 120, width: 240, height: 240)
    self.view.addSubview(wheel)
    wheel.addGestureRecognizer(TestRotateGestureRecognizer())
}

UIGestureRecognizer <- проблема здесь

import UIKit

class TestRotateGestureRecognizer: UIGestureRecognizer {
    var previousPoint = CGPoint()
    var currentPoint = CGPoint()
    var startAngle = CGFloat()
    var currentAngle = CGFloat()
    var currentRotation = CGFloat()
    var totalRotation = CGFloat()

    func angleForPoint(_ point:CGPoint) -> CGFloat{
        var angle = atan2(point.y - (self.view?.center.y)!, point.x - (self.view?.center.x)!)

        return angle
    }

    override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent) {
        super.touchesBegan(touches, with: event)
    }

    override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent) {
        super.touchesMoved(touches, with: event)

        if let firstTouch = touches.first {
            previousPoint = firstTouch.previousLocation(in: self.view)
            currentPoint = firstTouch.location(in: self.view)
            startAngle = angleForPoint(previousPoint)
            currentAngle = angleForPoint(currentPoint)

            currentRotation = currentAngle - startAngle
            totalRotation += currentRotation

            self.view?.transform = CGAffineTransform(rotationAngle: totalRotation)
        }
    }

    override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent) {
        super.touchesEnded(touches, with: event)
    }
}

Ответы на вопрос(1)

Ваш ответ на вопрос