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?