1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | - ( BOOL )application:( UIApplication *)application didFinishLaunchingWithOptions :( NSDictionary *)launchOptions {
//想摇你的手机嘛?就写在这,然后,然后,没有然后了
application .applicationSupportsShakeToEdit = YES ; } -( void )motionEnded:(UIEventSubtype)motion withEvent :( UIEvent *)event {
if (motion==UIEventSubtypeMotionShake) {
// 真实一点的摇动动画
[ self addAnimations ];
// 播放声音
AudioServicesPlaySystemSound (soundID);
} } - ( void )addAnimations {
CABasicAnimation *translation = [ CABasicAnimation animationWithKeyPath : @"transform" ];
translation .timingFunction = [ CAMediaTimingFunction functionWithName :kCAMediaTimingFunctionEaseInEaseOut];
translation .toValue =[ NSValue valueWithCATransform3D :CATransform 3 DMakeRotation(- M_PI_4 , 0 , 0 , 1 0 0 )];
translation .duration = 0 .2 ;
translation .repeatCount = 2 ;
translation .autoreverses = YES ;
[shake .layer addAnimation :translation forKey : @"translation" ]; } |
利用陀螺仪实现更真实的微信摇一摇动画
精选 转载
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
微信ipad协议
微信ipad最新版
微信 API sed -
android微信摇一摇(抽奖)
android微信摇一摇(抽奖)package com.example.sensoreventlistenertest;import java.util.Randomaye
android微信摇一摇抽奖 android 摇一摇 edn -
利用传感器实现微信的摇一摇功能android ide java 加速度传感器 bundle