Skip to content

Instantly share code, notes, and snippets.

@hmhmsh
Created November 30, 2017 05:15
Show Gist options
  • Save hmhmsh/5f6550923810f7972c51e51010fab282 to your computer and use it in GitHub Desktop.
Save hmhmsh/5f6550923810f7972c51e51010fab282 to your computer and use it in GitHub Desktop.
//
// 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
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment