iOS 添加震动结果
1. AudioServicesPlaySystemSound较早的系统版本,我们会利用AudioTool.framework。
#import <AudioToolbox/AudioToolbox.h>
一样平常震动
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
平常短震(类似3D Touch的 Peek 反馈 )
AudioServicesPlaySystemSound(1519);
平常短震 (类似3D Touch Pop 反馈)
AudioServicesPlaySystemSound(1520);
连续三次短震
AudioServicesPlaySystemSound(1521);
2. UIImpactFeedbackGenerator
iOS 10之后提供了UIImpactFeedbackGenerator
@interface UIImpactFeedbackGenerator : UIFeedbackGenerator
- (instancetype)initWithStyle:(UIImpactFeedbackStyle)style;
// 调用后开始震动
- (void)impactOccurred;
// 调用后开始震动,强度从0~1
- (void)impactOccurredWithIntensity:(CGFloat)intensity API_AVAILABLE(ios(13.0));
@end
UIImpactFeedbackStyle定义了震动的等级
typedef NS_ENUM(NSInteger, UIImpactFeedbackStyle) {
UIImpactFeedbackStyleLight,
UIImpactFeedbackStyleMedium,
UIImpactFeedbackStyleHeavy,
UIImpactFeedbackStyleSoft API_AVAILABLE(ios(13.0)),
UIImpactFeedbackStyleRigid API_AVAILABLE(ios(13.0))
};
UIImpactFeedbackGenerator利用
UIImpactFeedbackGenerator *generator = [ initWithStyle:UIImpactFeedbackStyleLight];
;
;
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
页:
[1]