IOS8 TabBarItem设置自定义图片问题

1 //IOS8以前使用的是:
2 
3 UITabBarItem *photoItem = [[UITabBarItem alloc] initWithTitle:@"首页" image:[UIImage imageNamed:@"app2"] tag:0];
4 
5 photo.tabBarItem = photoItem;
6 
7 [photo.tabBarItem setFinishedSelectedImage:[UIImage imageNamed:@"app1"] withFinishedUnselectedImage:[UIImage imageNamed:@"app2"]];
8 
9 [photoItem release];
  •  查看API之后看到使用了新的API方法
1 //使用新的API方法来初始化tabBarItem
2 - (instancetype)initWithTitle:(NSString *)title image:(UIImage *)image selectedImage:(UIImage *)selectedImage
3 //同时对使用的UIImage设置一下UIImageRenderingMode,使用UIImageRenderingModeAlwaysOriginal
4 
5 //用例:
6 UIImage * normalImage = [[UIImage imageNamed:@"nor.png"]  imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
7 UIImage * selectImage = [[UIImage imageNamed:@"select.png"]  imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
8      
9 UITabBarItem * tabBarItem = [[UITabBarItem alloc]initWithTitle:@"" image:normalImage selectedImage:selectImage];

 

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。