iOS UIFeedbackGenerator 系统触感反馈 震
2018-01-15 本文已影响810人
NieFeng1024
系统触感反馈
iOS 10之后出来的新API UIFeedbackGenerator
- 适用设备iPhone 7和iPhone 7 Plus上
![](https://img.haomeiwen.com/i1701168/ff590106f3b18a3a.png)
![](https://img.haomeiwen.com/i1701168/5de38b1f834407df.png)
![](https://img.haomeiwen.com/i1701168/27a60f9b57611842.png)
![](https://img.haomeiwen.com/i1701168/faad3a7913e7ebe5.png)
![](https://img.haomeiwen.com/i1701168/b75239ee39c45689.png)
![](https://img.haomeiwen.com/i1701168/2797e0e10f53b70d.png)
- (void)private_systemFeedbackGeneratorType:(AN_RESET_ACTION_TYPE)type {
if (type==AN_RESET_ACTION_FEEDBACK_LIGHT) {//轻度点击
UIImpactFeedbackGenerator *impactLight = [[UIImpactFeedbackGenerator alloc]initWithStyle:UIImpactFeedbackStyleLight];
[impactLight impactOccurred];
} else if (type==AN_RESET_ACTION_FEEDBACK_MEDIUM){//中度点击
UIImpactFeedbackGenerator *impactLight = [[UIImpactFeedbackGenerator alloc]initWithStyle:UIImpactFeedbackStyleMedium];
[impactLight impactOccurred];
} else if (type==AN_RESET_ACTION_FEEDBACK_HEAVY){//重度点击
UIImpactFeedbackGenerator *impactLight = [[UIImpactFeedbackGenerator alloc]initWithStyle:UIImpactFeedbackStyleHeavy];
[impactLight impactOccurred];
} else if (type==AN_RESET_ACTION_FEEDBACK_SELECTIONCHANGE){//选择切换
UISelectionFeedbackGenerator *feedbackSelection = [[UISelectionFeedbackGenerator alloc] init];
[feedbackSelection selectionChanged];
}
}