不耗费性能的切圆角

不耗费性能的切圆角

如何通过不使用简单的设置cornerRaidus为控件宽高的一半来切圆角呢?

我们可以添加一个UIImageView的分类来
添加下面的方法就可高性能的切圆角了

怎么样 是不是so easy 呢?
当然, 市面上还有更多的切圆角的方法, 这个可能不是性能最好的
但一定是性价比最高的

  • '' (void)getCircleImageWithImageView{
    ''
    '' UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds byRoundingCorners:UIRectCornerAllCorners cornerRadii:CGSizeMake(self.bounds.size.width / 2.0, self.bounds.size.height / 2.0)];
    ''
    '' CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
    '' maskLayer.path = maskPath.CGPath;
    ''
    '' self.layer.mask = maskLayer;
    '' }

以上

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容