0

UIViewボタンを押すか、タスクを完了すると、ストレッチとスキューのアニメーションを表示する必要があります。

適用されるアニメーションのほとんどは、UIView通常、に追加または削除されるときに適用されUIViewますが、ビューにすでに追加されているビューを使用してそれを実現するにはどうすればよいですか。

アニメーションは、ユーザーの注意を引く(タスクが完了したことを示す)限り、何でもかまいません。

4

2 に答える 2

1

編集 単一のアニメーションでビューを拡大縮小および回転する方法

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"];
于 2012-08-13T05:38:29.473 に答える
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;
    }];
}];
于 2012-08-13T06:08:46.037 に答える