我有一个联系人列表的uitableview。我希望将每个联系人的图像放在一个圈框中,就像在特立独行的登录屏幕中一样。任何建议如何在uitableviewCell中做到这一点?圆形框架中的图像iOS
22
A
回答
76
我相信你有你的imageView在你的Cell中,所以你只需要做一个效果就是使用一个不可见的边框。使用此代码使这个效果:
cell.yourImageView.layer.cornerRadius = cell.yourImageView.frame.size.height /2;
cell.yourImageView.layer.masksToBounds = YES;
cell.yourImageView.layer.borderWidth = 0;
你的UIImageView必须具有相同的高度和宽度,你也必须导入quartzCore框架项目
1
显然,我可以做一个圆角的矩形这样
float fw, fh;
if (ovalWidth == 0 || ovalHeight == 0) {
CGContextAddRect(context, rect);
return;
}
CGContextSaveGState(context);
CGContextTranslateCTM (context, CGRectGetMinX(rect), CGRectGetMinY(rect));
CGContextScaleCTM (context, ovalWidth, ovalHeight);
fw = CGRectGetWidth (rect)/ovalWidth;
fh = CGRectGetHeight (rect)/ovalHeight;
CGContextMoveToPoint(context, fw, fh/2);
CGContextAddArcToPoint(context, fw, fh, fw/2, fh, 1);
CGContextAddArcToPoint(context, 0, fh, 0, fh/2, 1);
CGContextAddArcToPoint(context, 0, 0, fw/2, 0, 1);
CGContextAddArcToPoint(context, fw, 0, fw, fh/2, 1);
CGContextClosePath(context);
CGContextRestoreGState(context);
,然后把图像里面,它会自动裁剪:
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSaveGState(context);
addRoundedRectToPath(context, self.frame, 10, 10);
CGContextClip(context);
[image drawInRect:self.frame];
CGContextRestoreGState(context);
相关问题
- 1. Android的圆形边框圆形图像
- 2. ios中的圆形图像视图
- 3. 使imagemagick中的图像圆形边框
- 4. 如何使图像适合Android的圆形框架
- 5. 圆形图像?
- 6. C中的圆形图框#
- 7. 使图像完全无边框圆形
- 8. 圆形图像或边框半径100%?
- 9. 将边框添加到圆形图像
- 10. 将边框添加到圆形图像
- 11. Css圆形图像
- 12. 检测图像中的圆形图案
- 13. div内的圆形图像
- 14. JavaFX的圆形图像
- 15. 圆形图像视图
- 16. 在iOS中绘制像线,圆,多边形,nurbs的图元
- 17. IOS中的图像变形
- 18. Android:环形内部的圆形图像
- 19. 圆形地图在iOS中查看
- 20. 在JAVA中的圆形运动图像
- 21. imagemagick中的图像圆形裁剪
- 22. Qt中的圆形图像Qml
- 23. 地图圆形边框webkit
- 24. 圆形图像文本
- 25. 圆形裁剪图像
- 26. 旋转圆形图像
- 27. Opencv - 圆形图像扭曲
- 28. 用asp.net圆形图像
- 29. 将图像制成圆形
- 30. UITableViewCell圆形图像查看
如果我的回答围绕你的问题接受PLZ –