iOS(学习7) 模态推送
2016-02-22 22:30
471 查看
模态推送 ViewController 推到 OneViewController
#import "ViewController.h" #import "OneViewController.h" @interface ViewController () @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; button.frame = CGRectMake(50, 250, 80, 30); [button setTitle:@"模态推送" forState:UIControlStateNormal]; [button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside]; [button setTitleColor:[UIColor grayColor] forState:UIControlStateNormal]; [self.view addSubview:button]; } - (void)buttonAction:(UIButton *)sneder { OneViewController *oneViewController = [[OneViewController alloc] init]; //模态视图推送动画 /* UIModalTransitionStyleCoverVertical UIModalTransitionStyleFlipHorizontal 180度翻转效果 UIModalTransitionStyleCrossDissolve 画面溶解效果 UIModalTransitionStylePartialCurl 翻页效果 */ oneViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve; [self presentViewController:oneViewController animated:YES completion:^{ NSLog(@"推送"); }]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } @end #import "OneViewController.h" @interface OneViewController () @end @implementation OneViewController - (void)viewDidLoad { [super viewDidLoad]; self.view.backgroundColor = [UIColor grayColor]; UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; button.frame = CGRectMake(50, 20, 50, 30); [button setTitle:@"返回" forState:UIControlStateNormal]; [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; [button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:button]; } - (void)buttonAction:(UIButton *)sender { [self dismissViewControllerAnimated:YES completion:^{ NSLog(@"返回"); }]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } /* #pragma mark - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { // Get the new view controller using [segue destinationViewController]. // Pass the selected object to the new view controller. } */ @end
相关文章推荐
- IOS基础之 (十) 内存管理
- iOS 数据存储的常用方式
- ios-基础用法之【6】-self. 与 下划线的区别
- iOS 手势(上)
- iOS下86版五笔输入法练习程序(作为备忘,最基本功能的演示demo,版本:0.99版)
- iOS开发中 [[NSBundle mainBundle] pathForResource: ofType:]路径为空的问题
- iOS 加密(MD5 ,AES,BASE64)
- ios-基础用法之【5】-define和const
- iOS 分类和继承
- iOS:KVO/KVC 的概述与使用
- iOS开发常用基础框架(你了解的ios只是冰山一角)
- iOS程序启动原理
- ios开发计算缓存的大小以及清除
- 关于c++浮点数的数字个数setprecision(n)与setiosflags(ios::fixed)
- iOS的23种设计模式简介
- iOS(学习8) 触摸
- IOS开发日志之CocoaPod的安装与简单使用Xcode7.2版本
- 【iOS】手势识别
- iOS开发手记-仿QQ音乐播放器动态歌词的实现
- iOS开发遇到 Missing iOS Distribution signing identity for XXXXXX