Created
June 12, 2013 14:08
-
-
Save advantis/5765588 to your computer and use it in GitHub Desktop.
Creating casual resizable image
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
// | |
// Copyright © 2013 Yuri Kotov | |
// | |
#import <UIKit/UIKit.h> | |
@interface UIImage (ADVImageResizing) | |
- (UIImage *) resizableImage; | |
@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
// | |
// Copyright © 2013 Yuri Kotov | |
// | |
#import "UIImage+ADVImageResizing.h" | |
#import <tgmath.h> | |
NS_INLINE UIEdgeInsets InsetsForSize(CGSize size) | |
{ | |
CGFloat top = floor(size.height / 2.f); | |
CGFloat left = floor(size.width / 2.f); | |
return UIEdgeInsetsMake(top, left, top - 1.f, left - 1.f); | |
} | |
@implementation UIImage (ADVImageResizing) | |
- (UIImage *) resizableImage | |
{ | |
return [self resizableImageWithCapInsets:InsetsForSize(self.size)]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment