代码:
UIImage *normal = [[UIImage imageNamed:@"tabbar_home_default"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
UIImage *selected = [[UIImage imageNamed:@"tabbar_home_selected"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
self.navigationController.tabBarItem.image = normal;
self.navigationController.tabBarItem.selectedImage = selected;
以上代码设置之后, 出现tabBarItem图片过大, 后来检查才发现, 原来图片发在了Images.xcassets中的x1位置, 改为x2位置之后就恢复正常了.
还有就是看看Images.xcassets中是不是有重复的图片.
时间: 2024-10-10 15:49:29