仅使用calayer's cornerRadius的某些角落的圆角图像 [英] rounded corner images for only certain corners with calayer's cornerRadius

查看:333
本文介绍了仅使用calayer's cornerRadius的某些角落的圆角图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图只围绕图像的左上角,因此它无法适当地适合组样式的tableviewcell。我可以用下面的代码四舍五入。有没有人知道一个简单的方法来获得四角形的一个角落?

I'm trying to only round the top left corner of an image so it can't fit appropriately into a group styled tableviewcell. I can get 4 corners rounded with the below code. Does anyone know a simple way to get just one of the corners rounded?

cell.imageView.layer.masksToBounds = YES;
cell.imageView.layer.cornerRadius = 5.0;

谢谢。

推荐答案

唯一可行的方法是用圆角绘制内容。您可以使用掩码属性来对任意角进行圆角处理,另一个图层具有您想要手动绘制的角,但速度要慢得多。如果你可以自己接管绘画,你应该这样做。

The only practical way to do that is to draw the content yourself with rounded corners. You can round arbitrary corners by using the mask property with another layer that has the corners you want rounded drawn by hand, but that's significantly slower. If you can possibly take over drawing yourself, you should do so.

这篇关于仅使用calayer's cornerRadius的某些角落的圆角图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆