I have a navigationBar with both Left and Right bar buttons on each side. I have a customTitlelabel
which I set as the titleView of the UINavigationItem
.
[self.navigationItem setTitleView:customTitleLabel];
All is fine now. The problem, the size of the rightbarButton is dynamic based on the input I get in one of the text fields.
Therefore the title is automatically centered based on the available space between the buttons.
how can i set the title to a fixed position?
The right answer is to override
sizeThatFits:
of your customtitleView
and return its content size. Navigation bar centers custom title view until it has no space left to do that.For example if you have
UIView
container withUILabel
inside: