码迷,mamicode.com
首页 > 移动开发 > 详细

iOS.iPad.03.UIModal

时间:2014-06-07 16:59:12      阅读:346      评论:0      收藏:0      [点我收藏+]

标签:c   style   class   blog   code   java   

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

bubuko.com,布布扣图01bubuko.com,布布扣图02

bubuko.com,布布扣图03bubuko.com,布布扣图04

bubuko.com,布布扣图05

2、代码

ViewController.h

bubuko.com,布布扣
#import <UIKit/UIKit.h>

@interface ViewController : UIViewController

- (IBAction)onclick:(id)sender;

@property (weak, nonatomic) IBOutlet UISegmentedControl *segControl;

@end
bubuko.com,布布扣

ViewController.m

bubuko.com,布布扣
#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
bubuko.com,布布扣

ModalViewController.h

bubuko.com,布布扣
#import <UIKit/UIKit.h>

@interface ModalViewController : UIViewController

- (IBAction)onclick:(id)sender;

@end
bubuko.com,布布扣

ModalViewController.m

bubuko.com,布布扣
#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
bubuko.com,布布扣

3、故事版

bubuko.com,布布扣

 

iOS.iPad.03.UIModal,布布扣,bubuko.com

iOS.iPad.03.UIModal

标签:c   style   class   blog   code   java   

原文地址:http://www.cnblogs.com/cqchen/p/3773918.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!