【问题标题】:Swift - Adjust Large Title in Navigation ControllerSwift - 在导航控制器中调整大标题
【发布时间】:2021-12-20 13:17:48
【问题描述】:

Image Link

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

我试图通过添加这个按钮将发现标题移动到这三个按钮的同一行,但它不起作用

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

在同一行中制作大标题的最佳方法是什么

【问题讨论】:

    标签: swift xcode user-interface titlebar ui-design


    【解决方案1】:

    不要使用大标题(不要勾选 Prefers Large Titles)

    您可以设置标题字体。

    StoryBoard -> NavigationController -> Title -> Title Text 属性,更改 Title Font Size

    如果要将标题放在导航栏的左侧,请使用leftBarButtonItem

    试试这个!

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

    【讨论】:

      猜你喜欢
      • 2011-11-30
      • 2019-06-13
      • 2011-04-19
      • 2015-06-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多