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