Multiple lines in UITabBarItem Label

前端 未结 4 1783
说谎
说谎 2021-01-19 12:06

I\'ve tried many things but impossible to find a way to put the label of a UITabBarItem with a lineNumber customised.0 (i would like to get the title on 2 lines).

Is

4条回答
  •  不思量自难忘°
    2021-01-19 12:48

    Now it contains two subviews. At 0 it is imageView and at 1 it is label. Now make the height of imageview a bit smaller so that you can give the height of label a bit larger to have multiple lines. Set the property ofnumberoflines of the label to 0 via code.

    let viewTabBar = tabBarItem.value(forKey: "view") as? UIView
    let imageView = viewTabBar?.subviews[0] as? UIImageView
    let label = viewTabBar?.subviews[1] as? UILabel
    

    and now play with this label.

提交回复
热议问题