ios - Adjusting views when Status Bar hides on rotation -


i've browsed around looking answer this, i've found people similar problems , not exact problem, here can me!

i have ipad app. on ipad, when hold ipad in either portrait or landscape, status bar clock , battery shown. reason, have custom toolbars @ top of of view controllers account 20 points.

i working on making app universal. first thing noticed when iphone in portrait mode status bar shown, when it's held in landscape mode, status bar hides , have toolbar 20 points tall.

i not interested in either hiding or showing status bar. think functionality of hiding on landscape mode on phone fine. want able detect when status bar hidden can adjust y position of toolbar (so make either 0 or -20). better solution if there's way me set layout constraints handle scenario.

the correct approach is:

  • use normal toolbar normal height - not set constraint on height.

  • add leading constraint 0 superview (not superview margin), trailing constraint 0 superview (not superview margin).

  • add top constraint 0 top layout guide. appear leave 20 pixels of space above toolbar, laugh evil laugh , proceed.

  • set view controller toolbar's delegate (there delegate outlet purpose).

  • have view controller adopt uibarpositioningdelegate , implement delegate method follows:

    class viewcontroller: uiviewcontroller, uibarpositioningdelegate {     func positionforbar(bar: uibarpositioning) -> uibarposition {         return .topattached     } } 

this cause apparent height of toolbar extended behind status bar when there status bar, have normal height , smack against top when there no status bar.

enter image description here enter image description here enter image description here


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -