//画一个圆角矩形
//简单的说就是8个点,分别是第边的中点(不局限于中点,只要比半径大就好)加各顶点就好,后面10是半径
CGRect rrect = CGRectMake(0.0,0.0,60.0,60.0); //位置+大小
CGFloat radius = 10.0;
//获取顶点坐标x,中间坐标x,最右坐标x
CGFloat minx = CGRectGetMinX(rrect), midx = CGRectGetMidX(rrect), maxx = CGRectGetMaxX(rrect);
CGFloat miny = CGRectGetMinY(rrect), midy = CGRectGetMidY(rrect), maxy = CGRectGetMaxY(rrect);
//从左边中心点开始
CGContextMoveToPoint(context, minx, midy);
CGContextAddArcToPoint(context, minx, miny, midx, miny, radius); //左上角点到上边中点
CGContextAddArcToPoint(context, maxx, miny, maxx, midy, radius); //右上角点到右边中点
CGContextAddArcToPoint(context, maxx, maxy, midx, maxy, radius); //右下角点到下边中点
CGContextAddArcToPoint(context, minx, maxy, minx, midy, radius); //左下角点到左边中心
CGContextClosePath(context); //完成一个循环,封闭起来
CGContextDrawPath(context, kCGPathFillStroke);
//画圆形图片(在UIImage+getegory里写)
#define MINSIZE(A,B) ((A)>=(B)?(B):(A))
//获取图片较小的边
CGFloat selfSize = MIN(self.size.width, self.size.height);
CGRect rect = CGRectMake(0, 0, selfSize, selfSize);
//根据一个rect创建一个椭圆(因为rect为正方形所以这里为圆)
CGContextAddEllipseInRect(context, rect);
//裁剪
CGContextClip(context);
//将原照片画到图形上下文中的rect范围里
[self drawInRect:rect];
//从上下文获取裁剪后的照片
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();