Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I wonder if its OK by iOS Human Interface Guidelines to style a UIView so it looks and acts like a navbar.

My problem is that I want to hide my current navbar once the user scrolls. I have tried both self.navigationController?.setNavigationBarHidden(true, animated: true) and navigationController?.hidesBarsOnSwipe = true but the animation looks odd, once the navigation bar gets hidden I still have about 20px space under the status bar: You can look at my other question

So to make things easier, can I just init my view tih the navbar hidden and style my own and add the proper animation?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
215 views
Welcome To Ask or Share your Answers For Others

1 Answer

Try this out :

extension YourViewController {
   override func prefersStatusBarHidden() -> Bool {
      return barsHidden // Custom property
   }

   override func preferredStatusBarUpdateAnimation() -> UIStatusBarAnimation {
      return .Slide
   }
}

You have to update barsHidden somewhere in the code and call setNeedsStatusBarAppearanceUpdate() method.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...