码迷,mamicode.com
首页 > 其他好文 > 详细

presentation Controllers的使用(二)

时间:2014-12-12 10:11:51      阅读:231      评论:0      收藏:0      [点我收藏+]

标签:presentation control   ios   

presentation Controllers的使用(二)

by 伍雪颖

bubuko.com,布布扣
bubuko.com,布布扣

model过去:
- (IBAction)show:(id)sender {
    SecondViewController *overlay = [[SecondViewController alloc] initWithCountry];
    [self presentViewController:overlay animated:YES completion:nil];
}

secondViewController.m
- (instancetype)initContentView {
    self = [super init];
    if (self) {
        [self setModalPresentationStyle:UIModalPresentationCustom];
        self.view.backgroundColor = [UIColor clearColor];
        self.contentContainerView = [[UIView alloc] initWithFrame:CGRectMake(20, 200, 280, 200)];
        self.contentContainerView.backgroundColor = [UIColor colorWithWhite:0.0 alpha:0.8];
        self.contentContainerView.layer.cornerRadius = 5.0;
        [self.view addSubview:self.contentContainerView];
       
        self.closeButton = [UIButton buttonWithType:UIButtonTypeSystem];
        self.closeButton.frame = CGRectMake(30, 30, 100, 100);
        self.closeButton.tintColor = [UIColor whiteColor];
        self.closeButton.titleLabel.font = [UIFont systemFontOfSize:13];
        [self.closeButton setTitle:@"Close" forState:UIControlStateNormal];
        [self.closeButton addTarget:self action:@selector(closeButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
        [self.contentContainerView addSubview:self.closeButton];
    }
    return self;
}

- (void)closeButtonPressed:(UIButton *)sender {
    [self.presentingViewController dismissViewControllerAnimated:YES completion:nil];
}


presentation Controllers的使用(二)

标签:presentation control   ios   

原文地址:http://blog.csdn.net/rainlesvio/article/details/41890391

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