Home > Blockchain >  Swift - Adjust Large Title in Navigation Controller
Swift - Adjust Large Title in Navigation Controller

Time:11-08

Image Link

 self.titleLabel.title = (NSLocalizedString("Discover", comment: "").localized(lang))

I tried to move the Discover Title to the same line that these three button by adding this one but it not worked

navigationItem.rightBarButtonItem?.setTitlePositionAdjustment(.init(horizontal: 10, vertical: 20), for: UIBarMetrics.default)

what is the best way to make the large title in the same line

CodePudding user response:

Don't use large title (Don't check Prefers Large Titles)

You can set the title font.

StoryBoard -> NavigationController -> Title -> Title Text Attributes, change Title Font Size

If you want to place the title on the left side of the navigation bar, Use leftBarButtonItem

Try this!

let titleLabel = UILabel()
titleLabel.text = "YourTitle"
titleLabel.font = UIFont.systemFont(ofSize: 30)
titleLabel.sizeToFit()
        
let leftItem = UIBarButtonItem(customView: titleLabel)
self.navigationItem.leftBarButtonItem = leftItem

  • Related