摇一摇
自带shake API
- (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event /** 检测到摇动 */ - (void)motionCancelled:(UIEventSubtype)motion withEvent:(UIEvent *)event /** 摇动取消(被中断) */ - (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event /** 摇动结束 */
摇一摇时开启震动
引入头文件
#import <AudioToolbox/AudioToolbox.h>
加入这句代码即可
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);