forked from jasarien/JSScrollableTabBar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUIImage+JSRetinaAdditions.m
More file actions
37 lines (29 loc) · 1.15 KB
/
UIImage+JSRetinaAdditions.m
File metadata and controls
37 lines (29 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//
// UIImage+JSRetinaAdditions.m
// JSScrollableTabBar
//
// Created by james on 16/07/2010.
// Copyright 2010 Truphone. All rights reserved.
//
#import "UIImage+JSRetinaAdditions.h"
@implementation UIImage (UIImage_JSRetinaAdditions)
- (id)initWithContentsOfResolutionIndependentFile:(NSString *)path
{
if ([UIScreen instancesRespondToSelector:@selector(scale)] && [[UIScreen mainScreen] scale] == 2.0)
{
NSString *path2x = [[path stringByDeletingLastPathComponent]
stringByAppendingPathComponent:[NSString stringWithFormat:@"%@@2x.%@",
[[path lastPathComponent] stringByDeletingPathExtension],
[path pathExtension]]];
if ([[NSFileManager defaultManager] fileExistsAtPath:path2x])
{
return [self initWithContentsOfFile:path2x];
}
}
return [self initWithContentsOfFile:path];
}
+ (UIImage *)imageWithContentsOfResolutionIndependentFile:(NSString *)path
{
return [[[UIImage alloc] initWithContentsOfResolutionIndependentFile:path] autorelease];
}
@end