forked from pilot34/P34Utils
/
UIImage+Utils.m
34 lines (27 loc) · 926 Bytes
/
UIImage+Utils.m
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
//
// UIImage+Utils.m
// iGuides
//
// Created by Глеб Тарасов on 22.01.12.
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//
#import "UIImage+Utils.h"
#import "UIImage+Resize.h"
@implementation UIImage (Utils)
- (UIImage *)stretchableImageByWidth
{
return [self stretchableImageWithLeftCapWidth:roundf(self.size.width / 2) topCapHeight:0];
}
- (UIImage *)stretchableImageByWidthAndHeight
{
return [self stretchableImageWithLeftCapWidth:roundf(self.size.width / 2) topCapHeight:roundf(self.size.height / 2)];
}
- (UIImage *)scaleForDimension:(CGFloat)min
{
CGFloat minSide = MIN(self.size.width, self.size.height);
CGFloat scale = min / minSide;
CGSize newSize = CGSizeMake((int)(self.size.width * scale),
(int)(self.size.height * scale));
return [self resizedImage:newSize interpolationQuality:kCGInterpolationDefault];
}
@end