UITabBarItem标签中的多行

问题描述:

我已经尝试了很多事情,但是找不到一种方法来将UITabBarItem的标签与lineNumber customized.0(我希望在两行上获得标题)联系起来.

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).

有办法吗?

现在它包含两个子视图.在0处是imageView,在1处是label. 现在,将imageview的高度减小一些,以便可以将标签的高度增大以具有多行.通过代码将标签的属性ofnumberoflines设置为0.

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

现在使用此标签.