I have a subclass of UIView
that I've added to as the titleView
of a navigationItem
using the following line of code:
self.navigationItem.titleView = tempview;
Easy enough. That works fine. My problem is that this navigationItem
sometimes has the rightBarButton
updated (sometimes there is no button, sometimes there is one standard sized button, sometimes there is a larger button).
I figured that I could simply use the layoutSubviews
method of the tempview
class that I've added as the titleView
so I put this in:
-(void)layoutSubviews {
[super layoutSubviews];
self.mylabel.frame = self.bounds;
}
This does not seem to work, as it does not correctly resize the titleview when the rightBarButton
item is updated.
I've noticed also that the bounds do not grow once they gotten smaller, they simply change the position.
I've tried using setNeedsLayout
and layoutIfNeeded
but those simply "resize" the view with the incorrect bounds.
I've also made sure that the rightBarButton
item is set to nil, but the view still does not correctly expand once shrunk.
Thanks for any help!