代码之家  ›  专栏  ›  技术社区  ›  abbood

如何减少UItabaritem图像和文本之间的垂直填充

  •  1
  • abbood  · 技术社区  · 7 年前

    enter image description here

    ie为了让它看起来像这样:

    enter image description here

    我尝试了以下代码:

        let pStyle = NSMutableParagraphStyle()
        pStyle.lineSpacing = -10.0
        UITabBarItem.appearance().setTitleTextAttributes([.paragraphStyle: pStyle], for: .normal)
    

    但它不起作用。思想?

    1 回复  |  直到 7 年前
        1
  •  8
  •   Callam    7 年前

    使用偏移量调整选项卡栏项目标题的位置。

    UITabBarItem.appearance().titlePositionAdjustment = UIOffset(horizontal: 0, vertical: -10)