创建两个视图控制器,加到导航控制器上
#import "AppDelegate.h"
#import "FirstViewController.h"
@interfaceAppDelegate ()
@end
@implementation AppDelegate
– (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
alloc] initWithFrame:[UIScreenmainScreen
backgroundColor = [UIColorwhiteColor];
makeKeyAndVisible];
FirstViewController *firstCtrl = [[FirstViewController
UINavigationController *navCtrl = [[UINavigationController
rootViewController = navCtrl;
returnYES;
}
在FirstViewController中导入SecondViewController
#import "FirstViewController.h"
#import "SecondViewController.h"
@interfaceFirstViewController ()
@end
@implementation FirstViewController
– (void)viewDidLoad {
[superviewDidLoad];
self.title =;
view.backgroundColor = [UIColorcyanColor];
buttonWithType:UIButtonTypeRoundedRect];
button.frame =CGRectMake(100,100, 100, 100);
[button setTitle:@"push"forState:UIControlStateNormal];
(buttonAction)forControlEvents:UIControlEventTouchUpInside];
[self.viewaddSubview:button];
}
//转场动画
– (void)transitionPush{
CATransition *tran = [CATransitionanimation];
tran.duration =.5;
tran.type =@"pageCurl";
tran.subtype =kCATransitionFromRight;
navigationController.view.layeraddAnimation:tran
}
//按钮的点击时间,,实现push动画效果
– (void)buttonAction{
[selftransitionPush];
SecondViewController *second = [[SecondViewController
pushViewController
}
SecondViewController.m中
#import "SecondViewController.h"
@interfaceSecondViewController ()
@end
@implementation SecondViewController
– (void)viewDidLoad {
[superviewDidLoad];
self.title =;
view.backgroundColor = [UIColororangeColor];
}
行动是治愈恐惧的良药,而犹豫、拖延将不断滋养恐惧。