views:

19

answers:

1

When a UIStatusBar is hidden in an app, the origin of all views is (0, 0), the upper left hand corner of the screen. However, when a statusBar is shown, the origin is still (0, 0) yet the views will move down as not to cover the statusBar.

How is this working? Is it possible to duplicate this effect in code?

Essentially, my end goal is to hide the statusBar and replace it with a UIView at certain points in the app. But I have a LOT of views and don't want to have to resize all of them after the statusBar is hidden.

+2  A: 

You could create a container view enclosing all your "normal" views and set autoresizing masks everywhere. That way, shrinking your container view will automatically resize everything else. In fact, this is how UIViewControllers work. But be aware that while standard Apple controllers like UINavigationController know how to deal with the status bar, they don't know anything about what you want to do, so they're going to be confused more often than not.

Alternatively, you can always show your own status bar underneath the real one, hiding the latter when needed. But in this case you will have to fight Apple-provided controllers which will try to expand when you hide the status bar. You can also play with a two-window layout where the top window does not overlap the status bar, but I'm not sure it will be any easier.

Since Apple doesn't support any of the above, expect a lot of things to stop working correctly. Perhaps, the very best approach is to rethink your UI design.

Costique