如何为自定义单元格设置角半径 [英] How to set a corner radius for a custom cell

查看:50
本文介绍了如何为自定义单元格设置角半径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的示例输出,在下面的详细信息中有三个单元格,我为每个自定义单元格设置了角半径.但它无法正常工作.第一个单元格的角半径不起作用,对于第二个单元格,顶部右侧和左上角正在工作,请说明该怎么做

Here is my sample output ,in that below details there are three cells ,i have set corner radius for each custom cells.but it not working correctly .The corner radius for first cell is not working ,for the second cell the top right and top left is working ,please say what to do for this

   -(void)layoutSubviews
     {
[super layoutSubviews];
self.backgroundColor = [UIColor clearColor];
self.contentView.layer.cornerRadius =5;
self.contentView.layer.masksToBounds = YES;

 }

我已将上述代码应用到我的单元格类文件中

i have applied this above code to my cell class file

推荐答案

在 cellForRowAtIndexPath 中使用

In cellForRowAtIndexPath Use

    cell.layer.cornerRadius=5

如果您在不同部分有不同的单元格,请确保为所有部分编写此代码

If you have different cells in different sections then make sure that this code is written for all sections

这篇关于如何为自定义单元格设置角半径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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