Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get max width of uinavigationItem.titleView?

I have a custom titleView that I need to set the max width for. That would be the screen width - width of left item (back title, button or nil) - width of right item (button or nil). How can I determine this?

Thanks.

like image 789
Stephanie Avatar asked May 23 '12 21:05

Stephanie


2 Answers

_segmentedControl.frame = CGRectMake(0, 0, CGFLOAT_MAX, _segmentedControl.frame.size.height);

[self.navigationItem setTitleView:_segmentedControl];

Setting CGFLOAT_MAX as width for the navigationItem title view use the maximum space available between the left item and the right item.

like image 100
Raphaël Pinto Avatar answered Nov 19 '22 20:11

Raphaël Pinto


Doesn't the navigationbar set the width to its maximum automatically? I mean, I'm sure the sizeThatFits: method of your custom titleView is called. Maybe this is a good starting point.

like image 24
Gwendal Roué Avatar answered Nov 19 '22 21:11

Gwendal Roué