- (IBAction)show:(id)sender {
SecondViewController *overlay = [[SecondViewController alloc] initWithCountry];
[self presentViewController:overlay animated:YES completion:nil];
}- (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的使用(二)
原文地址:http://blog.csdn.net/rainlesvio/article/details/41890391