您的位置:首页 > 移动开发 > IOS开发

ios代码设置圆角

2017-06-13 16:15 281 查看
- (UIImage *)obtainCircleImage {

UIGraphicsBeginImageContextWithOptions(self.size, NO, 0.0);

// 获取上下文

CGContextRef ref = UIGraphicsGetCurrentContext();

// 设置圆形

CGRect rect = CGRectMake(0, 0, self.size.width, self.size.height);

CGContextAddEllipseInRect(ref, rect);

// 裁剪

CGContextClip(ref);

// 将图片画上去

[self drawInRect:rect];

UIImage *image = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

return image;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: