将xCode升级到5.0.1后,4.0英寸背景图像变得更大

时间:2013-10-27 12:21:36

标签: xcode

当我跑3.5英寸时,游戏运行良好。 像这样: enter image description here

升级前,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英寸模式,图像变得像这样......

enter image description here

不确定发生了什么!!! 那么我怎样才能恢复它(在4英寸模式下也很好?)

提前致谢!!!

0 个答案:

没有答案