So I have an image that is a circle which I want to scale down to a new size.
When I scale down, the resultant is a square with the circle with diameter = side of the square, and there is a white background color. How do I get an image that is exactly the same shape?
+ (UIImage *)imageWithImage:(UIImage *)image customScaledToSize:(CGSize)newSize
{
//UIGraphicsBeginImageContext(newSize);
UIGraphicsBeginImageContextWithOptions(newSize, NO, [UIScreen mainScreen].scale);
[[UIColor clearColor] set];
UIRectFill(CGRectMake(0, 0, newSize.width, newSize.height));
[image drawInRect:CGRectMake(0, 0, newSize.width, newSize.height)];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return newImage;
}