1、美工做出2套图片,ios7以上使用的图片以_ios7结尾
2、扩展UIImage,创建UIImage+MJ,使用imageWithName方法替换imageByName
(1).h文件
#import
@interfaceUIImage (MJ)
/**
*加载图片
*
*@param name图片名
*/
+ (UIImage*)imageWithName:(NSString*)name;
@end
(2).m文件
#import"UIImage+MJ.h"
@implementationUIImage (MJ)
+ (UIImage*)imageWithName:(NSString*)name
{
if(iOS7) {
NSString*newName =
[namestringByAppendingString:@"_os7"];
UIImage*image = [UIImageimageNamed:newName];
if(image ==nil) {//没有_os7后缀的图片
image = [UIImageimageNamed:name];
}
returnimage;
}
//非iOS7
return[UIImageimageNamed:name];
}
@end