iOS present一个半透明控制器

2021-03-15  本文已影响0人  古轩沁夢

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];
}

上一篇 下一篇

猜你喜欢

热点阅读