views:

407

answers:

2

In my UIViewController i set my title dynamically so i do not know the length of the string that will be shown in the navigation bar and because of that i have the current situation: alt text

is there any way to set the width of the label that displays the title in the navigation bar? or should i think of a with, compare the text length to it and if it is too long should i resize it and display the famous "..." ?

I know that i can add an UILabel as subview to the navigationBar but i don't want to use that solution.

Thank you!

A: 

I'm not sure how you did that. If I'm creating a navigation view and setting a title that is too long it will be shortened with "..." by default. These black buttons do not seem to be default buttons.

Shingoo
they are added as subviews to the navigationBar because i want to change the background color to red and keep them black.
SorinA.
I don't think there is a way to shrink the labels width. If you don't want to use a UILabel as a sub view there will only be the "jessecurry"-way ;)
Shingoo
A: 

Maybe you could add some dummy buttons to the navigation bar that will sit directly underneath your buttons. That would show the normal text behavior, but also allow you to play with your colors.

jessecurry
thanks i'll give it a try now :)
SorinA.
thanks it worked!
SorinA.