iOS8 TabBarItem设置自定义图片问题

  • iOS8以前使用的方法
  • 查看API之后看到使用了新的API方法来初始化tabBarItem

iOS8以前使用的方法


UITabBarItem *photoItem = [[UITabBarItem alloc] initWithTitle:@"首页"
image:[UIImage imageNamed:@"app2"]
tag:0];

photo.tabBarItem = photoItem;

[photo.tabBarItem setFinishedSelectedImage:[UIImage imageNamed:@"app1"]
withFinishedUnselectedImage:[UIImage imageNamed:@"app2"]];

[photoItem release];

查看API之后看到使用了新的API方法来初始化tabBarItem

- (instancetype)initWithTitle:(NSString *)title
image:(UIImage *)image
selectedImage:(UIImage *)selectedImage

同时对使用的UIImage设置其UIImageRenderingMode属性为UIImageRenderingModeAlwaysOriginal

For example:

UIImage * normalImage = [[UIImage imageNamed:@"nor.png"]
imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
UIImage * selectImage = [[UIImage imageNamed:@"select.png"]
imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];

UITabBarItem * tabBarItem = [[UITabBarItem alloc] initWithTitle:@""
imageormalImage
selectedImage:selectImage];

再一次感谢您花费时间阅读这篇文章!

微博: @Danny_吕昌辉
博客: SuperDanny

你可能感兴趣的:(iOS8 TabBarItem设置自定义图片问题)