iOS开发17-iOS 模态视图的使用
来源:互联网 发布:跨境电商平台数据分析 编辑:程序博客网 时间:2024/04/29 18:39
iOS开发17-iOS 模态视图的使用
代码下载(Xcode7.0.1)有问题请联系博主,邮箱:nathanlee1987@aliyun.com
模态视图控制器并不是一个类,只是一种方式显示的controller。
在程序中切换页面可以使用UINavigationController,也可以使用模态视图。
IOS下的视图控制器都会有一个presentViewController方法,用来显示模态窗口,在一些特别的环境下我们尤其愿意使用这种窗口,例如临时呈现一些内容时(登录视图、分享列表视图等),所以今天在这里做一下整理。
代码:
-(void)buttonAction:(UIButton*)sender{ NextViewController *nextVC = [[NextViewController alloc]init]; nextVC.modalPresentationStyle=UIModalPresentationFormSheet; nextVC.modalTransitionStyle=UIModalTransitionStyleCoverVertical; /* 弹出View Controller时的风格 UIModalPresentationFullScreen UIModalPresentationPageSheet UIModalPresentationFormSheet UIModalPresentationCurrentContext UIModalPresentationCustom UIModalPresentationOverFullScreen UIModalPresentationOverCurrentContext UIModalPresentationPopover UIModalPresentationNone */ /*modalTransitionStyle场景切换动画的风格 UIModalTransitionStyleCoverVertical UIModalTransitionStyleFlipHorizontal UIModalTransitionStyleCrossDissolve UIModalTransitionStylePartialCurl */ [self presentModalViewController:nextVC animated:YES]; [self presentViewController:nextVC animated:YES completion:nil];}-(void)p_setupViews{ self.view.backgroundColor = [UIColor grayColor]; UIButton *button1 =[UIButton buttonWithType:UIButtonTypeCustom]; button1.frame = CGRectMake(100, 100, 150, 30); [button1 setTitle:@"显示模态视图" forState:UIControlStateNormal]; button1.backgroundColor=[UIColor orangeColor]; [self.view addSubview:button1]; [button1 addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];}- (instancetype)init{ self = [super init]; if (self) { [self p_setupViews]; } return self;}- (void)viewDidLoad { [super viewDidLoad]; }
返回代码:
-(void)buttonAction:(UIButton*)sender{ [self dismissViewControllerAnimated:YES completion:nil];}-(void)p_setupViews{ self.view.backgroundColor = [UIColor redColor]; UIButton *button1 =[UIButton buttonWithType:UIButtonTypeCustom]; button1.frame = CGRectMake(100, 100, 80, 30); [button1 setTitle:@"返回" forState:UIControlStateNormal]; button1.backgroundColor=[UIColor blueColor]; [self.view addSubview:button1]; [button1 addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside]; }- (instancetype)init{ self = [super init]; if (self) { [self p_setupViews]; } return self;}- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view.}
效果:
代码下载(Xcode7.0.1)
有问题请联系博主,邮箱:nathanlee1987@aliyun.com
著作权声明:本文由http://my.csdn.net/Nathan1987_原创,欢迎转载分享。请尊重作者劳动,转载时保留该声明和作者博客链接,谢谢
1 0
- iOS开发17-iOS 模态视图的使用
- ios-使用模态视图
- iOS开发-模态视图跳转
- iOS开发>>>UIScrollView滚动条视图的使用
- ios开发过程中添加新的视图使用UITabBarControl
- IOS开发之----UIScrollView滚动条视图的使用
- ios 模态视图
- iOS开发17:使用Navigation Controller切换视图
- iOS开发:使用ToolBar切换视图
- IOS学习笔记(十二)之IOS开发之表视图(UITableView)的讲解与使用(二)
- iOS开发-模式视图
- ios开发配置视图
- iOS开发:视图生命周期
- ios 开发--使用模态跳转了2次之后怎么从第三个视图控制器回到跟视图控制器
- IOS模态视图的创建
- iOS模态视图的使用方法
- IOS模态视图的创建
- iOS 模态视图,视图之间的切换
- Android应用开发判断一个Activity是否正在运行
- 新框架 之 EventBus
- noip 11.3~11.4模拟总结
- Oracle数据库安装图解
- 7.1面向对象概述
- iOS开发17-iOS 模态视图的使用
- 项目注释模板
- LightOJ - 1026 Critical Links(桥)
- Git学习(一) 版本管理工具
- iOS控件学习笔记(UIView、UIViewController)
- (学习笔记)栈数据结构中压(入)栈操作(C语言实现)
- 设置Ubuntu环境变量 PATH 的方法 及配置备份
- OC三大特性之一:封装的介绍
- RMAN - duplicate DATABASE