I\'m trying to build a titleView with constraints that looks like this:
I know how I would do
For combining auto-layout constraints inside titleView
and hardcoded layout logic inside UINavigationBar
you have to implement method sizeThatFits:
inside your own custom titleView
's class (subclass of UIView
) like this:
- (CGSize)sizeThatFits:(CGSize)size
{
return CGSizeMake(
CGRectGetWidth(self.imageView.bounds) + CGRectGetWidth(self.labelView.bounds) + 5.f /* space between icon and text */,
MAX(CGRectGetHeight(self.imageView.bounds), CGRectGetHeight(self.labelView.bounds))
);
}