- 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