UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(10, 100, 100, 50)];
button.backgroundColor = [UIColor grayColor];
[self.view addSubview:button];
[button addTarget:self action:@selector(jump) forControlEvents:UIControlEventTouchUpInside];
2.视图跳转
-(void)jump
{
firstViewController *first = [[firstViewController alloc] init];
first.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentViewController:first animated:YES completion:^{
NSLog(@"跳转完成");
}];
}
3.视图跳回(第二个视图)
创建按钮
UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(10, 100, 100, 50)];
button.backgroundColor = [UIColor redColor];
[self.view addSubview:button];
[button addTarget:self action:@selector(jumpBack) forControlEvents:UIControlEventTouchUpInside];
视图跳回
-(void)jumpBack
{
[self dismissViewControllerAnimated:YES completion:^{
NSLog(@"返回完成");
}];
}