设置头像圆角的三种方式
来源:互联网 发布:ubuntu 设置mac 编辑:程序博客网 时间:2024/05/16 18:49
设置圆角的方式
1.使用代码设置layer图层
2.使用runtime修改,在xib中点照相机,在User Defined Runtime Attributes修改
设置KeyPath 为layer.cornerRadius ,Type为Number ,Value为图片半径
下面(略)即可设置
3.对图片进行裁剪。生成一张新的图片
//1.开启图形上下文
//当前点与像素的比例 UIGraphicsBeginImageContextWithOptions(image.size, NO, 0);
// 2.描述裁剪区域
UIBezierPath *path = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(0, 0, image.size.width, image.size.height)];
// 3.设置裁剪区域
[path addClip];
// 4.画图片
[image drawAtPoint:CGPointZero];
// 5.取出图片
image = UIGraphicsGetImageFromCurrentImageContext();
// 6.关闭图形上下文
UIGraphicsEndImageContext();
_iconImage.image = image;
1.使用代码设置layer图层
2.使用runtime修改,在xib中点照相机,在User Defined Runtime Attributes修改
设置KeyPath 为layer.cornerRadius ,Type为Number ,Value为图片半径
下面(略)即可设置
3.对图片进行裁剪。生成一张新的图片
//1.开启图形上下文
//当前点与像素的比例 UIGraphicsBeginImageContextWithOptions(image.size, NO, 0);
// 2.描述裁剪区域
UIBezierPath *path = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(0, 0, image.size.width, image.size.height)];
// 3.设置裁剪区域
[path addClip];
// 4.画图片
[image drawAtPoint:CGPointZero];
// 5.取出图片
image = UIGraphicsGetImageFromCurrentImageContext();
// 6.关闭图形上下文
UIGraphicsEndImageContext();
_iconImage.image = image;
0 0
- 设置头像圆角的三种方式
- 设置头像圆角
- iOS图片设置圆角的三种方式
- cell设置圆角的三种方式
- iOS设置圆角的三种方式
- iOS设置圆角的三种方式
- iOS设置圆角的三种方式
- iOS设置圆角的三种方式
- iOS设置圆角的三种方式
- 头像设置(类似于CSDN的头像设置)
- response设置编码的三种方式
- LINUX设置环境变量的三种方式
- ubuntu设置代理 的三种方式
- response设置编码的三种方式
- response设置编码的三种方式
- VMware网络设置的三种方式
- 设置缓存失效的三种方式
- 设置缓存失效的三种方式
- 虚函数、抽象函数、接口的区别。
- 鸡年开工大吉
- 最新OCR文字识别软件如何提高OCR性能
- Echarts 通过时间轴timeline改变xAxis.data数据进行不合并处理
- 读《UML基础、案例与应用》有感
- 设置头像圆角的三种方式
- 人工智能、机器学习和深度学习三者的关系与应用
- Leetcode 105. Construct Binary Tree from Preorder and Inorder Traversal
- Python格式化输出
- 分区表
- 9.2 SO_REUSEADDR配置 & TCP_NODELAY
- LeetCode112. Path Sum java solution
- Leetcode 106. Construct Binary Tree from Inorder and Postorder Traversal
- Hibernate 中的 openSession和getCurrentSession 方法的区别