0

I have an app with a custom iOS navigation bar as in, I'm building it from scratch by subclassing UIView.

I want the navigation to extend from the top safe area or below the top status bar (depending on which iOS version & device we're talking about) a specific number of pixels. I also need it to extend all the way up to the very top of the screen regardless of the device as the navigation bar is translucent and should have content scrolling under it. That means the content would appear to be scrolling under the status bar and safe area.

I have successfully built a dynamic version of this that has no hardcoded values except for the knowledge of the status bar being 20px. It's pretty complex and prone to break. It also requires me to do a bunch of resizing in layoutSubviews as that's when you know the size of the safe area.

A much simpler solution would be detecting the device type and hard coding the height based on that but that feels wrong. What are the drawbacks of the hardcoded approach?

Tony
  • 18,776
  • 31
  • 129
  • 193
  • why are you creating a custom iOS nav bar? cant you modify the native one? (no hate.. just wondering which behaviour you cant achieve whith the native one) – Marcio Romero Patrnogic Jun 08 '18 at 17:35
  • i can't remember but im trying that again now. the UX is like snapchat if that gives you any insight as to why it at least wasn't originally the best idea – Tony Jun 08 '18 at 18:36
  • it comes down to just having a lot more control over the navigation bar but I am still attempting to use a modified native one. i posted a very specific question that addresses the first major wall i've come up against - https://stackoverflow.com/questions/50771879/how-do-i-hide-the-status-bar-in-an-ios-app-without-causing-the-uinavigationbar-t – Tony Jun 09 '18 at 07:23

0 Answers0