UIView
ボタンを押すか、タスクを完了すると、ストレッチとスキューのアニメーションを表示する必要があります。
適用されるアニメーションのほとんどは、UIView
通常、に追加または削除されるときに適用されUIView
ますが、ビューにすでに追加されているビューを使用してそれを実現するにはどうすればよいですか。
アニメーションは、ユーザーの注意を引く(タスクが完了したことを示す)限り、何でもかまいません。
UIView
ボタンを押すか、タスクを完了すると、ストレッチとスキューのアニメーションを表示する必要があります。
適用されるアニメーションのほとんどは、UIView
通常、に追加または削除されるときに適用されUIView
ますが、ビューにすでに追加されているビューを使用してそれを実現するにはどうすればよいですか。
アニメーションは、ユーザーの注意を引く(タスクが完了したことを示す)限り、何でもかまいません。
編集 単一のアニメーションでビューを拡大縮小および回転する方法
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"];
シンプルな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;
}];
}];