首页 > 代码库 > presentation Controllers的使用(二)
presentation Controllers的使用(二)
presentation Controllers的使用(二)
by 伍雪颖
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的使用(二)
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。