Last active
September 7, 2015 14:17
-
-
Save YGeorge/e0a7fbb479f572b64ba5 to your computer and use it in GitHub Desktop.
UIImage+Size category
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// UIImage+YGSize.h | |
// | |
#import <Foundation/Foundation.h> | |
@interface UIImage (YGSize) | |
+ (UIImage *)sizedImageWithName:(NSString *)name; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// UIImage+Size.m | |
// | |
#import "UIImage+YGSize.h" | |
@implementation UIImage (YGSize) | |
+ (UIImage *)sizedImageWithName:(NSString *)name { | |
UIImage *image; | |
if (IS_IPHONE_5) { | |
image = [UIImage imageNamed:[NSString stringWithFormat:@"%@-568h",name]]; | |
if (!image) { | |
image = [UIImage imageNamed:name]; | |
} | |
} | |
else if (IS_IPHONE_6) { | |
image = [UIImage imageNamed:[NSString stringWithFormat:@"%@-750w",name]]; | |
} | |
else { | |
image = [UIImage imageNamed:name]; | |
} | |
return image; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment