控制视图切换方向

1. 如果用presentModalViewController, 可以这样做:


Objective-C

1

2

3

4

5

6

- (IBAction)infoButtonPressed:(id)sender {

InfoViewController *infoViewController = [[InfoViewController alloc] initWithNibName: @"DAandPAInfo" bundle: [NSBundle mainBundle]];

self.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;

[self presentModalViewController: infoViewController animated: YES];

[infoViewController release];

}


2. 如果是pushViewController, 则复杂一点


CATransition *transition = [CATransition animation];

transition.duration = 1.0f;/* 间隔时间*/

transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];/* 动画的开始与结束的快慢*/

transition.type = @"reveal";/* 各种动画效果*/

//@"cube" @"moveIn" @"reveal" @"fade"(default) @"pageCurl" @"pageUnCurl" @"suckEffect" @"rippleEffect" @"oglFlip" @“twist”

transition.subtype = kCATransitionFromTop;/* 动画方向*/

//各种动画效果

/*

kCATransitionFade;

kCATransitionMoveIn;

kCATransitionPush;

kCATransitionReveal;

*/

/*

kCATransitionFromRight;

kCATransitionFromLeft;

kCATransitionFromTop;

kCATransitionFromBottom;

*/

transition.delegate = self;

[self.navigationController.view.layer addAnimation:transition forKey:nil];

TestViewController *next = [[TestViewController alloc] init];

[self.navigationController pushViewController: next animated:NO];



你可能感兴趣的:(控制视图切换方向)