Skip to content

Instantly share code, notes, and snippets.

@YGeorge
Last active September 7, 2015 14:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save YGeorge/e0a7fbb479f572b64ba5 to your computer and use it in GitHub Desktop.
Save YGeorge/e0a7fbb479f572b64ba5 to your computer and use it in GitHub Desktop.
UIImage+Size category
//
// UIImage+YGSize.h
//
#import <Foundation/Foundation.h>
@interface UIImage (YGSize)
+ (UIImage *)sizedImageWithName:(NSString *)name;
@end
//
// 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