当我运行 3.5 英寸时,游戏运行良好。像这样:
升级前,跑4.0寸也不错。像这样的代码:
#import <Foundation/Foundation.h>
@interface UIImage(iPhone5Extension)
+ (UIImage *)imageNamedWithiPhone5:(NSString *)name imageTyped:(NSString *)type;
@end
#import "UIImage+iPhone5.h"
@implementation UIImage(iPhone5Extension)
+ (UIImage *)imageNamedWithiPhone5:(NSString *)name imageTyped:(NSString *)type
{
NSString *imgName = nil;
if ([type length]==0) {
type = @"png";
} else {
type = type;
}
if (IS_IPHONE5) {
imgName = [NSString stringWithFormat:@"%@-568h",name];
} else {
imgName = name;
}
NSString *path = [[NSBundle mainBundle] pathForResource:imgName ofType:type];
UIImage *image = [UIImage imageWithContentsOfFile:path];
return image;
}
@end
然后在 ViewDidLoad :
- (void)viewDidLoad
{
[super viewDidLoad];
self.DefaultImageView.image = [UIImage imageNamedWithiPhone5: @"Title" imageTyped:@"png"];
}
但是,我有 3 种类型的图片:Title.png/Title@2x.png/Title-586h.png
但是升级到最新的xCode后,3.5寸还不错,但是4.0寸模式下,画面就变成了这样……
不知道怎么回事!!!那么我怎样才能恢复它(在 4 英寸模式下也很好?)
提前致谢!!!