0

I have created navigation bar with left bar button items using story board. Left bar button items include menu button, title button and search button as shown on below picture : Left bar items with navigation drawer

When i run the app with short text for title button it works fine as shown below: Short Text

Problem is when the text is long which makes other button disappear as shown below : long text problem

Title bar button text is not truncating string by tail after changing text. below is the code i'm using to change text

 TitleButton.setTitle(String(titleString.uppercased()) ,for: UIControl.State.normal)

After changing title text using above code, Title text style changed, text is overlapping and other bar items disappearing.

is there a way to force title button to truncate tail ?

5
  • try with TitleButton.titleLabel?.numberOfLines = 1 Commented Apr 11, 2023 at 20:03
  • 1
    Do you really want a button there? Or do you just want a title in the nav bar? Commented Apr 11, 2023 at 20:03
  • @FahimParkar I tried the code and it does not work for button Commented Apr 12, 2023 at 7:11
  • @Fogmeister i need the button to be on title bar to be able to open drop down list Commented Apr 12, 2023 at 7:12
  • You have to create a custom view and add it to the titleView of the navigationBar. self.navigationItem.titleView = yourView self.navigationController?.navigationBar.prefersLargeTitles = false Commented Apr 12, 2023 at 9:45

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.