2012-08-13 276 views
0

我需要按一下按鈕或任務完成時,彈出&傾斜動畫到UIView閃光/閃爍UIView

大多數應用於UIView動畫的時候都添加或刪除從UIView通常應用於但如何實現這一目標,以期已添加到查看。

動畫可以是任何東西,只要它吸引用戶的注意力(表明任務已完成)。

+0

那麼它是拉伸&歪斜或閃光? – 2012-08-13 05:31:33

+0

任何動畫都會執行:) – tGilani 2012-08-13 05:45:58

回答

1

編輯How to scale and rotate a view in a single animation

您可能需要使用核心動畫和組中添加兩個動畫:

CABasicAnimation *stetchAnimation = [CABasicAnimation animationWithKeyPath:@"transform.scale.x"]; 
stetchAnimation.toValue = [NSNumber numberWithDouble:(someView.frame.size.width+100)/someView.frame.size.width]; 

CABasicAnimation *skewAnimation = CABasicAnimation animationWithKeyPath:@"transform.rotation.x"]; 
stetchAnimation.toValue:[NSNumber numberWithInt:180]; 

//Add both animation at time when task is completed 

CAAnimationGroup *animationGroup = [CAAnimationGroup animation]; 
animationGroup.animations = [NSArray arrayWithObjects:stetchAnimation,skewAnimation,nil]; 
animationGroup.removedOnCompletion = YES; 
animationGroup.fillMode = kCAFillModeForwards; 
animationGroup.duration = 0.7; // increase duration if needed 

[someView.layer addAnimation:animationGroup forKey:@"animations"]; 
+0

當最後一行被執行時,即動畫被添加到圖層,視圖是否會開始動畫,或者我是否還需要做其他操作。 – tGilani 2012-08-13 05:48:15

+0

是的,它會開始動畫 – 2012-08-13 06:16:50

+0

http://stackoverflow.com/questions/9341332/how-to-scale-and-rotate-a-view-in-a-single-animation – 2012-08-13 06:47:49

1

簡單的UIView動畫;暫時增長的觀點:

[UIView animateWithDuration:0.3 animations:^{ 
    CGRect frm = view.frame; 
    frm.size.width += 20; 
    frm.size.height += 20; 
    frm.origin.x -= 10; 
    frm.origin.y -= 10; 
    view.frame = frm; 
} completion:^{ 
    [UIView animateWithDuration:0.3 animations:^{ 
     CGRect frm = view.frame; 
     frm.size.width -= 20; 
     frm.size.height -= 20; 
     frm.origin.x += 10; 
     frm.origin.y += 10; 
     view.frame = frm; 
    }]; 
}];