swift 单指旋转图片,超简单(已封存,开箱即用)

swift 单指旋转图片,超简单(已封存,开箱即用),第1张

使用方法:


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

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/996581.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-21
下一篇 2022-05-21

发表评论

登录后才能评论

评论列表(0条)

保存