答案 0 :(得分:4)
以下代码将为您提供帮助。您可以将颜色更改为所需的颜色,以达到所需的效果。
UIWindow *window = [[[UIApplication sharedApplication] delegate] window];
UIView *blue = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
[blue setBackgroundColor:[UIColor blueColor]];
[window addSubview: blueView];
Swift Code:
if let applicationDelegate:AppDelegate = UIApplication.shared.delegate as! AppDelegate? {
if let window:UIWindow = applicationDelegate.window {
let blueView:UIView = UIView(frame: UIScreen.main.bounds)
blueView.backgroundColor = UIColor.blue.withAlphaComponent(0.75)
window.addSubview(blueView)
}
}
答案 1 :(得分:0)
你可能想看看这个人的答案。
How to make a UIView that can cover the navigation bar?
基本上,不是将第二个视图设置为主视图的子视图,而是将第二个视图设置为导航控制器的子视图。