環境:Xcode 4.2 + iOS SDK 5
目標:
- 延續前例 ,將 View 切換時的畫面加上動畫的效果
- 編輯 HomeViewController.m,將 -(void) btnClicked:(id) sender 修改成這樣
-(void) btnClicked:(id) sender{
NSLog(@"button clicked !!");
secondViewController = [[SecondViewController alloc] initWithNibName:nil bundle:nil];
[UIView beginAnimations:@"flipping view" context:nil];
[UIView setAnimationDuration:1];
[UIView setAnimationCurve:UIViewAnimationOptionTransitionCurlDown];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.view.superview cache:NO];
[self.view.superview addSubview:secondViewController.view];
[UIView commitAnimations];
}
- 編輯 SecondViewController.m,將 -(void)btn2Pressed:(id)sender 修改成這樣
-(void)btn2Pressed:(id)sender{
NSLog(@"2ndView btn Pressed");
homeViewController = [[HomeViewController alloc] initWithNibName:nil bundle:nil];
[UIView beginAnimations:@"flipping view" context:nil];
[UIView setAnimationDuration:1];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.view.superview cache:NO];
[self.view.superview addSubview:homeViewController.view];
[UIView commitAnimations];
}
- 完工
沒有留言:
張貼留言