私は iPhone アプリケーションを開発しています。最初のビュー コントローラーをアニメーションでゆっくりと上に移動し、2 番目のビュー コントローラーに移動する必要があります。CoreAnimation を使用して、最初のビュー コントローラーをゆっくり上に移動し、次のビュー コントローラーにプッシュすることを考えています。これを達成するために利用できるクラス/ APIは何ですか?
ありがとうございました!
私は iPhone アプリケーションを開発しています。最初のビュー コントローラーをアニメーションでゆっくりと上に移動し、2 番目のビュー コントローラーに移動する必要があります。CoreAnimation を使用して、最初のビュー コントローラーをゆっくり上に移動し、次のビュー コントローラーにプッシュすることを考えています。これを達成するために利用できるクラス/ APIは何ですか?
ありがとうございました!
UIView
複数のを使用して、単一のView Controllerでこれを簡単に実現できます
Appleのドキュメントによると:
iOS 4 以降では、ブロックベースのアニメーション メソッドを使用します。
したがって、意図した結果を生成するには、次のコードを使用します。
UIView *mySecondView = [[UIView alloc] initWithFrame:CGRectMake(0, 480, 320, 480)];
[mySecondView setBackgroundColor:[UIColor redColor]];
[self.view addSubview:mySecondView];
[UIView animateWithDuration:2.0 delay:3.0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
[mySecondView setTransform:CGAffineTransformMakeTranslation(0, -480)];
}completion:^(BOOL done){
}];
これを試して、
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionNone forView:yourfirstview cache:YES];
[UIView setAnimationDidStopSelector:@selector(remove_view)];
//change frame here
yourfirstview.frame =CGRectMake(0,-480,320,480);
[UIView commitAnimations];
-(void)remove_view
{
[yourfirstview removeFromSuperview];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionNone forView:yoursecondview cache:YES];
//change frame here
yoursecondview.frame =CGRectMake(0,0,320,480);
[UIView commitAnimations];
}