今天突然发现iOS13下设置tabBarItem的文字位置的代码失效了,就是下面这句代码:
[[UITabBarItem appearance] setTitlePositionAdjustment:UIOffsetMake(0, -5)];
查了一下网上只有适配iOS13下的tabBarItem的文字的,却没有设置tabBarItem文字位置的代码,于是看了一下官方的文档,发现iOS13之后,tabbarItem的文字管理属性被UITabBarAppearance接管了,设置代码如下:
UITabBarAppearance *appearance = [UITabBarAppearance new];
appearance.stackedLayoutAppearance.normal.titlePositionAdjustment = UIOffsetMake(0, -5);
appearance.stackedLayoutAppearance.selected.titlePositionAdjustment = UIOffsetMake(0, -5);
nav.tabBarItem.standardAppearance = appearance;
如果有用的话,点个赞再走啊~~~