我创建了一个自定义的 UITableViewCell 类,我在其中创建了一个标签和 ImageView ,并通过 Storyboard 将它们连接起来。将圆角半径、边框宽度等应用于 imageView 的最佳位置是什么?
我在自定义类的 init 方法中尝试了以下方法,但效果不佳:
- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
productImageView.layer.borderColor = (__bridge CGColorRef)([UIColor whiteColor]);
productImageView.layer.borderWidth = 3.0f;
productImageView.layer.cornerRadius = 36.0f;
}
return self;
}
这里有什么问题吗?
最佳答案
您是在 UITableViewCell 子类中这样做吗?如果是这样,您需要在 awakeFromNib
或 prepareForReuse
中添加它。当调用 init 时, ImageView 还不存在。同时执行 self.productImageView.clipsToBounds = YES;
关于ios - 将圆角半径添加到 UITableViewCell 中的 ImageView 时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22874403/