iOS7 之后默认tabBar上按钮图片都会被渲染
解决方法:
-
1.直接修改图片
- 2.通过代码的形式
// 1. 创建图片
UIImage *image = [UIImage imageNamed:@"121_icon"];
// 2. 返回一个去掉渲染的图片赋值给原图片
image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
// 3. 设置tabbar
nav1.tabBarItem.selectedImage = image;
方法封装:
.h
#import <UIKit/UIKit.h>
@interface UIImage (Image)
/**传进一个图片名称,返回一个去掉渲染的图片*/
+ (UIImage *)imageOriginalWith:(NSString *)imageName;
@end
.m
#import "UIImage+Image.h"
@implementation UIImage (Image)
+ (UIImage *)imageOriginalWith:(NSString *)imageName
{
UIImage *image = [UIImage imageNamed:imageName];
return [image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
}
@end