设为首页 加入收藏

TOP

iOS 防止离屏渲染为 image 添加圆角
2019-08-31 01:02:48 】 浏览:27
Tags:iOS 防止 渲染 image 添加 圆角
 
 

// image 分类

- (UIImage *)circleImage{

    // NO 代表透明

    UIGraphicsBeginImageContextWithOptions(self.size, NO, 1);

    // 获得上下文

    CGContextRef ctx = UIGraphicsGetCurrentContext();

    // 添加一个圆

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

    // 方形变圆形

    CGContextAddEllipseInRect(ctx, rect);

    // 裁剪

    CGContextClip(ctx);

    // 将图片画上去

    [self drawInRect:rect];

    UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext();

    return image;

}


 

 

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇Objective-C Block与函数指针比较 下一篇报错:library not found for -ls..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目