我想删除屏幕顶部的状态栏。这不起作用:func application(application: UIApplication,didFinishLaunchingWithOptions launchOptions: NSDictionary?)-> Bool{ application.statusBarHidden = true return true}我也尝试过:func application(application: UIApplication,didFinishLaunchingWithOptions launchOptions: NSDictionary?)-> Bool{ self.window = UIWindow(frame: UIScreen.mainScreen().bounds) var controller = UIViewController() application.statusBarHidden = true controller.setNeedsStatusBarAppearanceUpdate() var view = UIView(frame: CGRectMake(0, 0, 320, 568)) view.backgroundColor = UIColor.redColor() controller.view = view var label = UILabel(frame: CGRectMake(0, 0, 200, 21)) label.center = CGPointMake(160, 284) label.textAlignment = NSTextAlignment.Center label.text = "Hello World" controller.view.addSubview(label) self.window!.rootViewController = controller self.window!.makeKeyAndVisible() return true}
3 回答
慕运维8079593
TA贡献1876条经验 获得超5个赞
您确实应该在视图控制器上实现preferredsStatusBarHidden:
Swift 3及更高版本
override var prefersStatusBarHidden: Bool {
return true
}
幕布斯7119047
TA贡献1794条经验 获得超8个赞
如果要在按钮水龙头上隐藏并恢复状态栏,而在显示和关闭幻灯片菜单,弹出窗口等时,则可以使用以下方法:
隐藏状态栏:-
UIApplication.shared.keyWindow?.windowLevel = UIWindowLevelStatusBar
恢复状态栏:-
UIApplication.shared.keyWindow?.windowLevel = UIWindowLevelNormal
- 3 回答
- 0 关注
- 1102 浏览
添加回答
举报
0/150
提交
取消