在TabBarItem设计的时候不需要title只要image的时候,如何将image居中显示。

tabBarItem.imageInsets = UIEdgeInsetsMake(6, 0, -6, 0);

这边用到的是TabBarItem的imageInsets属性:

UIEdgeInsets设置偏移量
UIEdgeInsetsMake(CGFloat top, CGFloat left, CGFloat bottom, CGFloat right)

这边重要的一点是,top和bottom要设置成相反数,不然image的大小会一直改变。

相关文章:

  • 2022-12-23
  • 2021-07-20
  • 2021-08-25
  • 2021-12-09
  • 2022-01-12
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-26
  • 2022-12-23
  • 2022-12-23
  • 2022-02-15
  • 2022-12-23
  • 2021-03-31
  • 2022-03-02
相关资源
相似解决方案