我使用以下代码切换显示我的工具栏和导航栏:
override func viewDidLoad() {
super.viewDidLoad()
//set up gesutre to recognise tap
let tapGestureRecognizer = UITapGestureRecognizer(target:self, action:Selector("toggle:"))
scrollView.userInteractionEnabled = true
scrollView.addGestureRecognizer(tapGestureRecognizer)
}
func toggle(sender: AnyObject) {
navigationController?.setNavigationBarHidden(navigationController?.navigationBarHidden == false, animated: true)
navigationController?.setToolbarHidden(navigationController?.toolbarHidden == false, animated: true)
}
override func prefersStatusBarHidden() -> Bool {
return navigationController?.navigationBarHidden == true
}
override func preferredStatusBarUpdateAnimation() -> UIStatusBarAnimation {
return UIStatusBarAnimation.Slide
}
我目前在scrollView中有一个图像。动画导航栏时,它会向下滑动图像,当导航栏动画化后,它会向上滑动图像。如何阻止这种情况发生,以便工具栏显示在图像顶部向下滑动?