Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple lines in UITabBarItem Label

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 there a way to do it?

like image 641
Kevin Vacquier Avatar asked Sep 14 '17 12:09

Kevin Vacquier


Video Answer


1 Answers

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.

like image 107
Arnav Avatar answered Oct 05 '22 22:10

Arnav