摇一摇
- motionBegan 手势开始(开始摇了)
- motionCancelled 手势取消(取消摇)
一般在手势结束(结束摇)的时候进行操作
判断一下事件的类型是否为shake
- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event {
NSLog(@"摇了一摇");
if (event.subtype == UIEventSubtypeMotionShake) {
self.view.backgroundColor = [UIColor orangeColor];
}
}
本文介绍了iOS中如何实现摇一摇手势的识别,并通过UIEvent的subtype属性来判断是否为shake手势,进而改变视图背景颜色。
1073

被折叠的 条评论
为什么被折叠?



