博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
iOS.iPad.03.UIModal
阅读量:4562 次
发布时间:2019-06-08

本文共 2382 字,大约阅读时间需要 7 分钟。

1、案例介绍:iPad上使用多种风格的ModalView,如图01,02,03,04,05

图01图02

图03图04

图05

2、代码

ViewController.h

#import 
@interface ViewController : UIViewController- (IBAction)onclick:(id)sender;@property (weak, nonatomic) IBOutlet UISegmentedControl *segControl;@end

ViewController.m

#import "ViewController.h"#import "ModalViewController.h"@interface ViewController ()@end@implementation ViewController- (void)viewDidLoad{    [super viewDidLoad];    // Do any additional setup after loading the view, typically from a nib.}- (void)didReceiveMemoryWarning{    [super didReceiveMemoryWarning];    // Dispose of any resources that can be recreated.}- (IBAction)onclick:(id)sender {        ModalViewController *modalViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"modalViewController"];        modalViewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;        switch (self.segControl.selectedSegmentIndex) {        case 0:            modalViewController.modalPresentationStyle = UIModalPresentationFullScreen;            break;        case 1:            modalViewController.modalPresentationStyle = UIModalPresentationPageSheet;            break;        case 2:            modalViewController.modalPresentationStyle = UIModalPresentationFormSheet;            break;        default:            modalViewController.modalPresentationStyle = UIModalPresentationCurrentContext;            break;    }        [self presentViewController:modalViewController animated:YES completion:nil];        }@end

ModalViewController.h

#import 
@interface ModalViewController : UIViewController- (IBAction)onclick:(id)sender;@end

ModalViewController.m

#import "ModalViewController.h"@interface ModalViewController ()@end@implementation ModalViewController- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil{    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];    if (self) {        // Custom initialization    }    return self;}- (void)viewDidLoad{    [super viewDidLoad];    // Do any additional setup after loading the view.}- (void)didReceiveMemoryWarning{    [super didReceiveMemoryWarning];    // Dispose of any resources that can be recreated.}- (IBAction)onclick:(id)sender {    [self dismissViewControllerAnimated:YES completion:nil];}@end

3、故事版

 

转载于:https://www.cnblogs.com/cqchen/p/3773918.html

你可能感兴趣的文章
24点游戏 程序(二)
查看>>
linux ----> centos 网络、tomcat、vi、等等的配置和使用
查看>>
Hive导入数据
查看>>
【剑指offer】数值的整数次方
查看>>
CentOS 7 系统服务详解
查看>>
最小生成树------Kruskal算法
查看>>
手动构建镜像
查看>>
实际描述和固定描述的取值
查看>>
MyEclipse优化设置(最详细版本)
查看>>
Company & Corporation
查看>>
如何在github pages中创建自己的Jekyll博客并绑定域名(2018-11-29)
查看>>
java--final 类在程序中的影响
查看>>
mysql主从复制,及扩展
查看>>
[Leetcode] Linked list cycle ii 判断链表是否有环
查看>>
Java设计模式之《代理模式》及应用场景
查看>>
iOS中的请求下载和直接下载的区别
查看>>
【Linux基础】vim使用技巧(未整理)
查看>>
CODEFORCES掉RATING记 #5
查看>>
flash钟表的实现
查看>>
Linux Centos7 解决数据库5.7版本乱码问题
查看>>