如何为自定义单元格设置角半径

Cha*_*esh 2 uitableview ios xcode6

在此处输入图片说明

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

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

 }
Run Code Online (Sandbox Code Playgroud)

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

Res*_*der 5

在 cellForRowAtIndexPath 中使用

    cell.layer.cornerRadius=5
Run Code Online (Sandbox Code Playgroud)

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