在我的项目中,我已经在iPhone上实现了摇晃手势。我想保存用户特定的摇晃模式(比如像单词“S”一样的摇晃),并且只需要在特定的模式下调用事件。这在iPhone上是否可行?如果可能,可以有人给我提供一些参考吗?
阅读Core motion编程指南和Core motion框架参考,理解iPhone设备运动API,您将能够实现自定义的运动事件。
我认为从这里可以了解如何在iPhone上实现震动效果,或者您也可以使用
CABasicAnimation *theAnimation;
theAnimation=[CABasicAnimation animationWithKeyPath:@"transform.translation.x"];
theAnimation.duration=1;
theAnimation.repeatCount=2;
theAnimation.autoreverses=YES;
theAnimation.fromValue=[NSNumber numberWithFloat:0];
theAnimation.toValue=[NSNumber numberWithFloat:-60];
[view.layer addAnimation:theAnimation forKey:@"animateLayer"];
希望能对您有所帮助