【发布时间】:2014-12-13 15:22:10
【问题描述】:
请帮忙。如何在iOS 8上为模态视图制作清晰的颜色,这样写
self.view.superview.backgroundColor = [UIColor clearColor];
在 iOS 7 上工作,但在 iOS 8 上不工作。变得清晰但不完全
【问题讨论】:
标签: ios objective-c ios8 modalviewcontroller
请帮忙。如何在iOS 8上为模态视图制作清晰的颜色,这样写
self.view.superview.backgroundColor = [UIColor clearColor];
在 iOS 7 上工作,但在 iOS 8 上不工作。变得清晰但不完全
【问题讨论】:
标签: ios objective-c ios8 modalviewcontroller
尝试像这样更改 alpha 值:-
[[UIColor clearColor] colorWithAlphaComponent:0.6];
【讨论】:
如果你为 UIViewController 主视图设置了背景颜色,你需要在之前设置它:
- (void)setupModalPresentationStyle
{
self.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0")) {
self.modalPresentationStyle = UIModalPresentationOverFullScreen;
}
}
- (void)awakeFromNib
{
[super awakeFromNib];
[self setupModalPresentationStyle];
}
当你呈现这个 UIViewController 时,你需要设置当前呈现的 UIViewController:
- (void)doneButtonTap:(id)sender {
self.modalPresentationStyle = UIModalPresentationCurrentContext;
[self presentViewController:detailsViewController animated:YES completion:nil];
}
【讨论】: