Krishna Raj Salim
Krishna Raj Salim

Reputation: 7390

How to make the title label to be fit within the back button of UInavigation controller :XCode

I'm using navigation controller in one of my apps, and I am troubling with the title of navigation controller back button. I want

solution 1: to make the title label to be fit within the back button area (something like:adjustsFontSizeToFitWidth=YES)

or

solution2: to make the back button large enough to hold the text.

(solution 1 is more preferable).

For more info, I'm giving an image here...


enter image description here

fig1: Good for short titletext.

fig2: Title get truncated for long text.

fig3: Make the text self adjustable.

fig4: Make the button large enough to hold the text.


Thanks in advance... :)

Upvotes: 2

Views: 313

Answers (2)

Pratik
Pratik

Reputation: 2399

put below code in you .m file button will auto resize with title

-(void)viewDidAppear:(BOOL)animated
{
     self.navigationController.navigationBar.backItem.title = @"Back";//put here your title
}

you will be succeed

Upvotes: 0

Balu
Balu

Reputation: 8460

In IOSX ,till now apple not providing the permissions for customising the back button in navigation controller ,for achieving your requirement you can use your custom button because we are not having permissions for changing the back button frame.

Upvotes: 3

Related Questions