我见过一个应用程序,他们可以根据滚动位置动态调整状态栏高度/y 位置。
这是一个示例 gif: https://gyazo.com/ec8e3fa336098305e6a5aedc68118789
这是我得到的
override var prefersStatusBarHidden: Bool {
return isStatusBarHidden
}
override var preferredStatusBarUpdateAnimation: UIStatusBarAnimation {
if !isStatusBarHidden {
return UIStatusBarAnimation.fade
} else {
return UIStatusBarAnimation.slide
}
}
func changeStatusBarStatus(status: Bool) {
isStatusBarHidden = status
UIView.animate(withDuration: 0.3, delay: 0, options: [.allowUserInteraction], animations: {
self.setNeedsStatusBarAppearanceUpdate()
})
}
最佳答案
创建自定义StatusBar
首先隐藏您的默认
statusBar
对于整个应用程序,在Status bar is initially hidden
中添加 YES/TRUE在info.plist
这将隐藏
StatusBar
从应用程序除非您以编程方式添加重新显示它。然后添加
UIView
在你的ViewController
并给它顶部、左侧和右侧constraint
(0,0,0) 引用View
(不引用Safe Area
)然后将其向下或底部
constraint
0 引用您的主要工作UIView
看,我已经在我的应用中创建了一个类似的底部 View (您只需在创建 constraint
时反转此 StatusBar
)
(注意:如果您看不到 UIView
,请使用以 iPhone 10 或 11 系列的方式查看,这样您就可以将其与其他 UIView
清楚地区分开来)
关于ios - 是否可以更改状态栏高度/y 位置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59402734/