使用方法:
let oneRotate = UIOneFingerRotationGes(target: self, action: #selector(oneFingerRotateAction(ges:)))
compassImgV.addGestureRecognizer(oneRotate)
@objc private func oneFingerRotateAction(ges: UIOneFingerRotationGes) {
compassImgV.transform = compassImgV.transform.rotated(by: ges.rotation)
}
工具类:
// Created by hdf on 2022/3/31.
import UIKit
class UIOneFingerRotationGes: UIGestureRecognizer {
var rotation: CGFloat = 0.0
override func touchesBegan(_ touches: Set, with event: UIEvent) {
if (event.touches(for: self)?.count ?? 0) > 1 {
self.state = .failed
}
}
override func touchesMoved(_ touches: Set, with event: UIEvent) {
if self.state == .possible {
self.st
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)