// MyFirstViewController.h
// MyUI6-1
//
// Created by tlh on 16/3/14.
// Copyright © 2016年 lamco. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "MySecondViewControler.h"
@interface MyFirstViewController : UIViewController
@property(strong,nonatomic)UIButton *btn;
@end
// MyFirstViewController.m
// MyUI6-1
//
// Created by tlh on 16/3/14.
// Copyright © 2016年 lamco. All rights reserved.
//
#import "MyFirstViewController.h"
@interface MyFirstViewController ()
@end
@implementation MyFirstViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor=[UIColor blueColor];
self.btn=[UIButton buttonWithType:UIButtonTypeRoundedRect];
self.btn.frame=CGRectMake(100, 100, 100, 50);
self.btn.backgroundColor=[UIColor greenColor];
[self.btn addTarget:self action:@selector(next) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:self.btn];
}
-(void)next
{
MySecondViewControler *mysec=[[MySecondViewControler alloc]init];
// 设置模态视图页面切换方式
mysec.modalTransitionStyle=3;
// 模态视图
[self presentViewController:mysec animated:YES completion:^{NSLog(@"页面切换完毕");}];
}
// MySecondViewControler.h
// MyUI6-1
//
// Created by tlh on 16/3/14.
// Copyright © 2016年 lamco. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "MyThirdViewController.h"
@interface MySecondViewControler : UIViewController
@property(strong,nonatomic)UIButton *btn;
// Created by tlh on 16/3/14.
// Copyright © 2016年 lamco. All rights reserved.
//
#import "MySecondViewControler.h"
@interface MySecondViewControler ()
@end
@implementation MySecondViewControler
- (void)viewDidLoad {
[super viewDidLoad];
self.btn=[UIButton buttonWithType:UIButtonTypeRoundedRect];
self.btn.frame=CGRectMake(100, 100, 100, 50);
self.btn.backgroundColor=[UIColor redColor];
[self.btn addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:self.btn];
self.view.backgroundColor=[UIColor greenColor];
}
-(void)back
{
隐藏 返回上一页
// [self dismissViewControllerAnimated:YES completion:^{
// NSLog(@"front page show");
// }];
MyThirdViewController *mysec=[[MyThirdViewController alloc]init];
[self presentViewController:mysec animated:YES completion:^{NSLog(@"页面切换");}];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
// MyThirdViewController.h
// MyUI6-1
//
// Created by tlh on 16/3/14.
// Copyright © 2016年 lamco. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "MyFirstViewController.h"
@interface MyThirdViewController : UIViewController
@property(strong,nonatomic)UIButton *btn;
@end
// MyThirdViewController.m
// MyUI6-1
//
// Created by tlh on 16/3/14.
// Copyright © 2016年 lamco. All rights reserved.
//
#import "MyThirdViewController.h"
@interface MyThirdViewController ()
@end
@implementation MyThirdViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor=[UIColor redColor];
// self.btn=[UIButton buttonWithType:UIButtonTypeRoundedRect];
// self.btn.frame=CGRectMake(100, 100, 100, 50);
// self.btn.backgroundColor=[UIColor greenColor];
// [self.btn addTarget:self action:@selector(next) forControlEvents:UIControlEventTouchUpInside];
// [self.view addSubview:self.btn];
// Do any additional setup after loading the view.
}
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
[self presentViewController:[MyFirstViewController new] animated:YES completion:nil];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}