// 使用原始图片
img = [img imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
// 设置选中后的图片
tabBarController.tabBar.selectedItem.selectedImage = img;
// 设置tabBarItem图片居中
for (UITabBarItem * item in self.tabBarController.tabBar.items)
for (UITabBarItem * item in self.tabBarController.tabBar.items)
{
item.imageInsets = UIEdgeInsetsMake(5, 0, -5, 0);
item.imageInsets = UIEdgeInsetsMake(5, 0, -5, 0);
}
本文介绍如何在iOS应用中使用Swift代码设置TabBar图标显示为原始图片而非模板图片,并调整选中状态下的图片以及使图标居中显示的方法。
762

被折叠的 条评论
为什么被折叠?



