swift - 加速器/摇一摇功能

import UIKit

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
    }


    override func motionBegan(_ motion: UIEvent.EventSubtype, with event: UIEvent?) {
     
        print("摇一摇开始")
    }
    
    override func motionEnded(_ motion: UIEvent.EventSubtype, with event: UIEvent?) {
        print("摇一摇结束")
    }
    
    override func motionCancelled(_ motion: UIEvent.EventSubtype, with event: UIEvent?) {
        print("摇一摇取消")
    }
}

  

猜你喜欢

转载自www.cnblogs.com/qingzZ/p/10286915.html