iOS--创建圆角图片的又一方法
UIImage+additions.h
#import <UIKit/UIKit.h> @interface UIImage (additions) -(UIImage*)makeRoundCornersWithRadius:(const CGFloat)RADIUS; @endUIImage+additions.m
#import "UIImage+additions.h" @implementation UIImage (additions) -(UIImage*)makeRoundCornersWithRadius:(const CGFloat)RADIUS { UIImage *image = self; // Begin a new image that will be the new image with the rounded corners // (here with the size of an UIImageView) UIGraphicsBeginImageContextWithOptions(image.size, NO, image.scale); const CGRect RECT = CGRectMake(0, 0, image.size.width, image.size.height); // Add a clip before drawing anything, in the shape of an rounded rect [[UIBezierPath bezierPathWithRoundedRect:RECT cornerRadius:RADIUS] addClip]; // Draw your image [image drawInRect:RECT]; // Get the image, here setting the UIImageView image //imageView.image UIImage* imageNew = UIGraphicsGetImageFromCurrentImageContext(); // Lets forget about that we were drawing UIGraphicsEndImageContext(); return imageNew; } @end