iPhone上的搖一搖
作者:leoios
iPhone上的搖一搖實現(xiàn)很簡單。具體參考下面的代碼或者下載Demo試一下。
源碼簡介:iPhone上的搖一搖實現(xiàn)很簡單。具體參考下面的代碼或者下載Demo試一下。
源碼效果:
源碼片段:
- #pragma mark - 搖動
- /**
- * 搖動開始
- */
- - (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event {
- if (motion == UIEventSubtypeMotionShake) {
- NSLog(@"開始搖了");
- }
- }
- /**
- * 搖動結(jié)束
- */
- - (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event {
- NSLog(@"搖動結(jié)束");
- }
- /**
- * 搖動取消
- */
- - (void)motionCancelled:(UIEventSubtype)motion withEvent:(UIEvent *)event {
- NSLog(@"搖動取消");
- }
責(zé)任編輯:倪明
來源:
github