实现类似iphone手机删除应用程序的抖动效果

来源:互联网 发布:广联达计价软件购买 编辑:程序博客网 时间:2024/05/22 10:53

其实原理很简单,让图片向左,再向右旋转一定角度就可以啦

static BOOL wobblesLeft = NO;

    UIButton * button=[UIButton buttonWithType:UIButtonTypeCustom];
    [button setImage:[UIImage imageNamed:@"宝宝日记_1.png"] forState:UIControlStateNormal];
    button.frame=CGRectMake(10, 10, 40, 40);
    CGFloat rotation=(3*M_PI)/180;
    CGAffineTransform wobbleLeft=CGAffineTransformMakeRotation(rotation);
    CGAffineTransform wobbleRight=CGAffineTransformMakeRotation(-rotation);
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.2];
    [UIView setAnimationDelegate:self];
    [UIView setAnimationRepeatCount:999999999];
    button.transform = wobblesLeft ? wobbleRight : wobbleLeft;
    wobblesLeft = !wobblesLeft;
    [UIView commitAnimations];
    [self.view addSubview:button];


原创粉丝点击