微信的摇一摇动画效果看起来很棒,这里是类似的摇一摇动画效果,代码示例:
| 代码如下 | 复制代码 |
| #pragma mark - 摇一摇 - (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event { if (motion == UIEventSubtypeMotionShake) { AudioServicesPlaySystemSound(kSystemSoundID_Vibrate); //震动效果 [self shakeView:phoneImgView]; //这里的phoneImgView是需要摇动效果的图片控件 } } #pragma mark - 动画 -(void)shakeView:(UIView*)viewToShake { CGFloat t = 14.0; CGAffineTransform translateRight = CGAffineTransformTranslate(CGAffineTransformIdentity, t, 0.0); CGAffineTransform translateLeft = CGAffineTransformTranslate(CGAffineTransformIdentity, -t, 0.0); viewToShake.transform = translateLeft; [UIView animateWithDuration:0.08 delay:0.0 options:UIViewAnimationOptionAutoreverse|UIViewAnimationOptionRepeat animations:^{ [UIView setAnimationRepeatCount:5.0]; viewToShake.transform = translateRight; } completion:^(BOOL finished){ if(finished){ [UIView animateWithDuration:0.08 delay:0.0 options:UIViewAnimationOptionBeginFromCurrentState animations:^{ viewToShake.transform =CGAffineTransformIdentity; } completion:NULL]; } }]; } | |
注:需要震动效果时,要导入AudioToolbox.framework,然后导入头文件”AudioToolbox/AudioToolbox.h”,实现的摇一摇动画效果看起来还不错,可以在自己的工程里试一试。
韩剧再婚皇后阿里云盘全集高清1080P资源链接-韩剧再婚皇后免费阿里云盘资源下载4K高清无删减版链接
poipiku网站如何打开-poipiku官网网页版访问入口
明日方舟:终末地-云游戏畅玩入口-明日方舟:终末地-网页版在线直连地址
poki在线小游戏网页版-poki免费游戏大全入口
poki游戏入口-点开即玩-poki游戏-在线免费畅玩
原神akt大佬资源viciNeko入口链接-原神akt大佬资源网页vicineko入口链接分享