iOS图标抖动效果
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了iOS图标抖动效果相关的知识,希望对你有一定的参考价值。
开始抖动
-(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图标抖动效果的主要内容,如果未能解决你的问题,请参考以下文章