Skip to content

Instantly share code, notes, and snippets.

@ourui
Created January 4, 2016 03:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ourui/3e039684711885604f9d to your computer and use it in GitHub Desktop.
Save ourui/3e039684711885604f9d to your computer and use it in GitHub Desktop.
UIImgage+antialiasing
#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