2012-08-13 319 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; 
    }]; 
}];