-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathUIImage_TLCommon.m
More file actions
31 lines (25 loc) · 879 Bytes
/
UIImage_TLCommon.m
File metadata and controls
31 lines (25 loc) · 879 Bytes
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
//
// UIImage_TLCommon.m
// TLCommon
//
// Created by Joshua Bleecher Snyder on 9/7/09.
//
#import "UIImage_TLCommon.h"
#import "CGGeometry_TLCommon.h"
@implementation UIImage (TLCommon)
+ (UIImage *)imageWithName:(NSString *)fileName {
return [[self class] imageWithName:fileName extension:@"png"];
}
+ (UIImage *)imageWithName:(NSString *)fileName extension:(NSString *)fileExtension {
NSString *imagePath = [[NSBundle mainBundle] pathForResource:fileName ofType:fileExtension];
return [[self class] imageWithContentsOfFile:imagePath];
}
// modified from https://devforums.apple.com/message/75921#75921
- (UIImage *)imageScaledToSize:(CGSize)size {
UIGraphicsBeginImageContext(size);
[self drawInRect:CGRectZeroWithSize(size)];
UIImage *scaledImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return scaledImage;
}
@end