Skip to content

Instantly share code, notes, and snippets.

@SwiftSIQI
Last active September 19, 2022 07:19
Show Gist options
  • Select an option

  • Save SwiftSIQI/5f1ed731f73d68ea10f3b6b8faebab40 to your computer and use it in GitHub Desktop.

Select an option

Save SwiftSIQI/5f1ed731f73d68ea10f3b6b8faebab40 to your computer and use it in GitHub Desktop.
- (UIImage *)antiAlias
{
CGFloat border = 1.0f;
CGRect rect = CGRectMake(border, border, self.size.width-2*border, self.size.height-2*border);
UIImage *img = nil;
UIGraphicsBeginImageContext(CGSizeMake(rect.size.width,rect.size.height));
[self drawInRect:CGRectMake(-1, -1, self.size.width, self.size.height)];
img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIGraphicsBeginImageContext(self.size);
[img drawInRect:rect];
UIImage* antiImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return antiImage;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment