hmhmsh
11/30/2017 - 5:15 AM

Shake of motion

// 
//  MotionShake.swift
// 

override func canBecomeFirstResponder() -> Bool {
    return true
}
    
override func motionBegan(motion: UIEventSubtype, withEvent event: UIEvent?) {
    if event!.type == UIEventType.Motion && event!.subtype == UIEventSubtype.MotionShake {
        // シェイク動作始まり時の処理
        // shake`s motion is beginning
    }
}
    
override func motionEnded(motion: UIEventSubtype, withEvent event: UIEvent?) {
    if event!.type == UIEventType.Motion && event!.subtype == UIEventSubtype.MotionShake {
        // シェイク動作終了時の処理
        // shake`s motion is finished
	}
}