3D Touch参考文章
旧机型
1> 导入头文件 #import <AudioToolbox/AudioServices.h>
这三个接口是系统 私有接口可能审核不过
Peek 震动反馈 (weak boom)
AudioServicesPlaySystemSound(1519);
Pop 震动反馈 (strong boom)
AudioServicesPlaySystemSound(1520);
三次连续震动
AudioServicesPlaySystemSound(1521);
新机型 6s以上
// iphone 7 手机10.0 以上版本才可以使用一下三个新接口, 其他的手机无效
- (IBAction)shake4:(UIButton *)sender {
UIImpactFeedbackGenerator *generator =
[[UIImpactFeedbackGenerator alloc] initWithStyle: UIImpactFeedbackStyleLight];
[generator prepare];
[generator impactOccurred];
}
- (IBAction)shake5:(UIButton *)sender {
UIImpactFeedbackGenerator *generator =
[[UIImpactFeedbackGenerator alloc] initWithStyle: UIImpactFeedbackStyleMedium];
[generator prepare];
[generator impactOccurred];
}
- (IBAction)shake6:(UIButton *)sender {
UIImpactFeedbackGenerator *generator =
[[UIImpactFeedbackGenerator alloc] initWithStyle: UIImpactFeedbackStyleHeavy];
[generator prepare];
[generator impactOccurred];
}
github 地址
网友评论