您的位置:首页 > 产品设计 > UI/UE

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

2012-06-15 10:16 489 查看
其实原理很简单,让图片向左,再向右旋转一定角度就可以啦

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];
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  iphone 手机 uiview button