ios - Dynamically increase/decrease height of custom UINavigationBar -
i followed blog post explains how can implement custom uinavigationbar
has increased height, if example wanted put additional ui elements in nav bar underneath rest of bar content persist between navigation on stack. code works in case want increased height.
in app, need start navigation bar @ default height, increase later, adding more content, after user performs given action. similar song info , controls in itunes store:
so put checks in place not reposition if bool
property no
. when set yes
, call [self setneedsdisplay]
call layoutsubviews
position appropriately based on boolean value. sizethatfits
called , return proper height.
the problem is, can't call [self settransform:cgaffinetransformmaketranslation(0, -(navigationbarheightincrease))];
in initialize
. instead call @ same time change boolean value yes
. because of this, of elements moved amount. if don't call settransform
, elements in nav bar in proper position, bar positioned far down, custom view i've added bar shown overtop view controller's view - bleeds out, , space added black not navigation bar's background color.
if call settransform
in initialize
, when height default height, elements moved when shouldn't be.
so, how can dynamically change height , positioning of uinavigationbar
subclass?
as suggested in comments, achieve behavior custom navigation bar (not subclassing native control) persists across pushes , pops of controllers in navigation controller, you'll need have single controller custom navigation bar , single embedded view resolves uinavigationcontroller
view controllers underneath. then, necessary set navigation controller's delegate root controller title , other properties can updated sub-controllers pushed , popped. i've provided screenshot below of storyboard version of might like:
Comments
Post a Comment