我试过在Swift中创建一个类,它在1秒后自动隐藏我的UIStatusBar
和我的navigationController
。 我的问题是,StatusBar
不会消失。这就是我得到的:UIStatusBar不会消失
override func viewDidLoad() {
super.viewDidLoad()
NSTimer.scheduledTimerWithTimeInterval(1.0, target: self, selector: "prefersStatusBarHidden", userInfo: nil, repeats: false)
}
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
}
override func preferredStatusBarUpdateAnimation() -> UIStatusBarAnimation {
return UIStatusBarAnimation.Fade
}
override func prefersStatusBarHidden() -> Bool {
if (barcounter == 0){
hide()
barcounter = 1
return true
}
else {
show()
barcounter = 0
return false
}
}
@IBAction func picturePressed(sender: AnyObject) {
prefersStatusBarHidden()
}
func hide(){
UIView.animateWithDuration(1, delay: 1, options: UIViewAnimationOptions.CurveEaseOut, animations: {
self.navigationController?.navigationBar.alpha = 0.0
}, completion: nil)
}
func show(){
UIView.animateWithDuration(1, delay: 1, options: UIViewAnimationOptions.CurveEaseOut, animations: {
self.navigationController?.navigationBar.alpha = 1.0
}, completion: nil)
}
所以我已经尝试过,你可以在看到上面的示例是很重要的我例如.. 现在我删除它,并尝试第二个。这一个为我工作,但不正确。此刻状态栏是隐藏的,但导航控制器不会隐藏 –
没关系 - 它的工作原理:D谢谢 –
嘿,如果它的工作,那么请批准答案,这样有助于其他 –