【发布时间】:2014-05-27 10:57:04
【问题描述】:
当我使用自定义模式视图控制器时尝试使背景视图变暗,我将背景颜色设置为灰色,不透明度为 0.5:
- (void)rulesTapped:(id)sender
{
RulesVC *rulesVC = [[RulesVC alloc] init];
self.view.backgroundColor = [UIColor colorWithRed:0.3 green:0.3 blue:0.3 alpha:0.5];
rulesVC.modalPresentationStyle = UIModalPresentationCustom;
rulesVC.transitioningDelegate = self;
[self presentViewController:rulesVC animated:YES completion:nil];
}
但是当我在关闭模态 VC 时尝试将其设置回 whiteColor(或黄色)时,这种变暗保持在原位:
- (void) gotItTapped:(id)sender
{
[self.presentingViewController.view setBackgroundColor:[UIColor yellowColor]];
[self dismissViewControllerAnimated:YES completion:nil];
}
为什么?有没有办法在不添加另一个覆盖视图而只使用现有视图操作的情况下使背景变暗(然后移除变暗)视图?
【问题讨论】: