Created
January 4, 2016 03:12
-
-
Save ourui/3e039684711885604f9d to your computer and use it in GitHub Desktop.
UIImgage+antialiasing
This file contains hidden or 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
#import "UIImage+Antialiase.h" | |
@implementation UIImage (Antialiase) | |
//创建抗锯齿头像 | |
- (UIImage*)antialiasedImage{ | |
return [self antialiasedImageOfSize:self.size scale:self.scale]; | |
} | |
//创建抗锯齿头像,并调整大小和缩放比。 | |
- (UIImage*)antialiasedImageOfSize:(CGSize)size scale:(CGFloat)scale{ | |
UIGraphicsBeginImageContextWithOptions(size, NO, scale); | |
[self drawInRect:CGRectMake(1, 1, size.width-2, size.height-2)]; | |
UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); | |
UIGraphicsEndImageContext(); | |
return image; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment