码迷,mamicode.com
首页 > 移动开发 > 详细

iOS图标抖动效果

时间:2016-02-27 19:22:53      阅读:234      评论:0      收藏:0      [点我收藏+]

标签:

开始抖动

-(void)BeginWobble
{

    srand([[NSDate date] timeIntervalSince1970]);
    float rand=(float)random();
    CFTimeInterval t=rand*0.0000000001;

    [UIView animateWithDuration:0.1 delay:t options:0  animations:^
     {
         要抖动的视图.transform=CGAffineTransformMakeRotation(-0.05);
     } completion:^(BOOL finished)
     {
         [UIView animateWithDuration:0.1 delay:0 options:UIViewAnimationOptionRepeat|UIViewAnimationOptionAutoreverse|UIViewAnimationOptionAllowUserInteraction  animations:^
          {
              要抖动的视图.transform=CGAffineTransformMakeRotation(0.05);
          } completion:^(BOOL finished) {}];
     }];
}

停止抖动

-(void)EndWobble
{

    [UIView animateWithDuration:0.1 delay:0 options:UIViewAnimationOptionAllowUserInteraction|UIViewAnimationOptionBeginFromCurrentState animations:^
     {
         要抖动的视图.transform=CGAffineTransformIdentity;
     } completion:^(BOOL finished) {}];
}
 

iOS图标抖动效果

标签:

原文地址:http://www.cnblogs.com/wanghuaijun/p/5223316.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!