實現類似iphone手機刪除應用程序的抖動效果

其實原理很簡單,讓圖片向左,再向右旋轉一定角度就可以啦

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];


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章