iOS.iPad.03.UIModal

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

iOS.iPad.03.UIModal图01iOS.iPad.03.UIModal图02

iOS.iPad.03.UIModal图03iOS.iPad.03.UIModal图04

iOS.iPad.03.UIModal图05

2、代码

ViewController.h

iOS.iPad.03.UIModal
#import <UIKit/UIKit.h>

@interface ViewController : UIViewController

- (IBAction)onclick:(id)sender;

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

@end
iOS.iPad.03.UIModal

ViewController.m

iOS.iPad.03.UIModal
#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
iOS.iPad.03.UIModal

ModalViewController.h

iOS.iPad.03.UIModal
#import <UIKit/UIKit.h>

@interface ModalViewController : UIViewController

- (IBAction)onclick:(id)sender;

@end
iOS.iPad.03.UIModal

ModalViewController.m

iOS.iPad.03.UIModal
#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
iOS.iPad.03.UIModal

3、故事版

iOS.iPad.03.UIModal

 

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

iOS.iPad.03.UIModal

上一篇:织梦M手机端/自适应网站内容图片变形解决办法


下一篇:小明种苹果(续)