想必大家都知道,在iOS 4.x上,要兼容iPhone 3Gs和iPhone4 的高清屏幕,只需要做两套图片。
image.png和image@2x.png 然后 UIImage *aImage = [UIImage imageNamed:"imag"];
糟糕的是:
现在有一台8GB的iPhone 3G+iOS3.1.3
在iOS 3.x上根本不支持自动识别后缀的方式加载图片,可以通过下面的方法解决
+(UIImage*)super_imageNamed:(NSString*)name{
if ([[UIDevice currentDevice].systemVersion floatValue] >= 4.0) {
return [UIImage imageNamed:name];
}else {
return [UIImage imageNamed:[NSString stringWithFormat:@"%@.png",name]];
}
}
好啦,这样就支持iPhone 3Gs和iPhone 4,也支持IOS 3.x和iOS 4.x了。(当然没有同学会给你的iPhone 4 来个IOS 3.x吧,虽然jobs今天归隐了,iPhone5不久还是会出来的)