iOS present一个半透明控制器

A控制器present一个半透明的B控制器

    BViewController *bVC = [[BViewController alloc] init];
    [self presentViewController:bVC animated:YES completion:nil];

在BViewController.m文件中加入

//设置控制器透明
- (UIModalPresentationStyle)modalPresentationStyle {
    return UIModalPresentationOverCurrentContext;
}

//控制器弹出方式
- (UIModalTransitionStyle)modalTransitionStyle {
    return UIModalTransitionStyleCoverVertical;
}

- (void)viewDidLoad{
    [super viewDidLoad];
    //*设置半透明背景
    self.view.backgroundColor = [UIColor colorWithWhite:0 alpha:0.5];
}

你可能感兴趣的:(iOS present一个半透明控制器)