设置为UIImageRenderingModeAlwaysOriginal
就会显示出选中状态的图片。当然普通状态的也需要设置。
UINavigationController *nav =({
UINavigationController *controller = [[UINavigationController alloc]initWithRootViewController:rootVC];
[controller.tabBarItem setTitle:title];
UIImage *selectImage = ({
UIImage *image = [UIImage imageNamed:selectString];
UIImageRenderingModeAutomatic, // Use the default rendering mode for the context where the image is used
UIImageRenderingModeAlwaysOriginal, // Always draw the original image, without treating it as a template
UIImageRenderingModeAlwaysTemplate, // Always draw the image as a template image, ignoring its color
image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
image;
});
[controller.tabBarItem setSelectedImage:selectImage];
[controller.tabBarItem setImage:[UIImage imageNamed:normalString]];
controller;
});