UIImageView添加圆角优化
来源:互联网 发布:猎头 知乎 编辑:程序博客网 时间:2024/06/08 09:42
imgView.layer.cornerRadius = 10;// 这一行代码是很消耗性能的imgView.clipsToBounds = YES;
**这是离屏渲染(off-screen-rendering),消耗性能的**
给UIImage添加生成圆角图片的扩展API:这是on-screen-rendering
- (UIImage *)imageWithCornerRadius:(CGFloat)radius {CGRect rect = (CGRect){0.f, 0.f, self.size}; UIGraphicsBeginImageContextWithOptions(self.size, NO, UIScreen.mainScreen.scale);CGContextAddPath(UIGraphicsGetCurrentContext(), [UIBezierPath bezierPathWithRoundedRect:rect cornerRadius:radius].CGPath);CGContextClip(UIGraphicsGetCurrentContext()); [self drawInRect:rect];UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return image;}
0 0
- UIImageView添加圆角优化
- UIImageView添加圆角
- UIImageView添加圆角
- 给UIImageView 添加圆角
- UIImageView添加圆角图片
- UIImageView圆角实现
- UIImageView加上圆角
- UIImageView设定圆角
- UIImageView 添加Button 不起作用
- UIImageView 添加事件
- UIImageView 添加手势
- UIimageView添加点击事件
- UIImageView添加点击事件
- UIImageView 性能优化
- UILable UIImageView 设置圆角
- UIImageView 的圆角效果
- UIImageView圆角设置swift
- 给UIImageView添加点击效果
- The 10th Zhejiang Provincial Collegiate Programming Contest
- C++如何在程序运行中获得int等数据类型的最大值
- 顶点缓存对象(VBO)
- ZOJ 39352016
- MSSQL2008 性能优化
- UIImageView添加圆角优化
- 确实还是字典法方便
- hibernate 映射文件的学习
- 纯虚函数
- sublime批量添加注释
- Android:复杂滚动布局的终极适配
- ZOJ 3931Exact Compression
- Java的getClass()
- Android懒人库----ButterKnife