Xcode加载图片

例如:[UIImage imageName:@“home”]; 加载png 图片

home.png
home@2x.png
home-568h@2x.png
 ========================================
一、非retina 屏幕 (都是3.5 inch ,分辨率:320 * 480)   //1/3G/3GS
     会自动加载home.png
 
二、retina 屏幕
1、3.5 inch (640 * 960)      //  iPhone4/iPhone4S
     会自动加载home@2x.png
 
2、4.0 inch (640 * 1136)    //  iPhone5/iPhone5S/iPhone5C
(1) home-568h@2x.png(如果home 是程序的启动图片,才自动加载)
(2) 如果是retina屏幕,并且不是程序的启动图片,则会自动加载home@2x.png
 
===================================================
一、 home如果是启动图片
iPhone  1/3G/3GS , 3.5 inch, 非retina屏幕, 自动加载 home.png
iPhone  4/4S , 3.5 inch, retina屏幕, 自动加载 home@2x.png
iPhone 5/5S/5C , 4.0inch , retina屏幕, 自动加载 home-568@2x.png
 
二、 home如果不是启动图片
iPhone  1/3G/3GS , 3.5 inch, 非retina屏幕, 自动加载 home.png
iPhone  4/4S , 3.5 inch, retina屏幕, 自动加载 home@2x.png
iPhone 5/5S/5C , 4.0inch , retina屏幕, 自动加载 home@2x.png
 
****************************** 总结 ****************************
home.png :3.5 inch + 非retina 屏幕
home@2x.png :retina屏幕
home-568@2x.png :4.0 inch +retina屏幕 + home是程序的启动图片
 
 
static Singleton *_instance;

+ (instancetype)allocWithZone:(struct _NSZone *)zone{
    
    @synchronized (self) {
        if (!_instance) {
            _instance = [super allocWithZone:zone];
        }
    }
    return _instance;
}

+ (instancetype)shareTools{
    
    @synchronized (self) {
        if (!_instance) {
            _instance = [[self alloc] init];
        }
    }
    
//    static dispatch_once_t onceToken;
//    dispatch_once(&onceToken, ^{
//        _instance = [[self alloc] init];
//    });
    return _instance;
}

- (instancetype)copyWithZone:(NSZone *)zone{

    return _instance;
}

- (instancetype)mutableCopyWithZone:(NSZone *)zone{

    return _instance;
}

 

 
 
static Singleton *_instance;
+ (instancetype)allocWithZone:(struct _NSZone *)zone{
    static dispatch_once_t onceToken;
    
    dispatch_once(&onceToken, ^{
        _instance = [super allocWithZone:zone];
    });

    return _instance;
}


+ (instancetype)shareTools{

    return [[self alloc] init];
}

- (id)copyWithZone:(NSZone *)zone{

    return _instance;
}

- (id)mutableCopyWithZone:(NSZone *)zone{

    return _instance;
}

 

posted @ 2017-02-07 10:58  王卓越  阅读(985)  评论(0编辑  收藏  举报