闪光/闪烁UIView

时间:2012-08-13 05:13:50

标签: iphone ios ios5 uiviewanimation

我需要给予一些延伸和放大按下按钮或完成任务后,将动画倾斜到UIView

应用于UIView的大多数动画通常在UIView添加或删除时应用,但如何通过已添加到视图中的视图来实现。

动画可以是任何东西,只要它吸引用户注意(表示任务已完成)。

2 个答案:

答案 0 :(得分:1)

编辑 How to scale and rotate a view in a single animation

您可能需要使用Core 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"];

答案 1 :(得分: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;
    }];
}];