ios - 将圆角半径添加到 UITableViewCell 中的 ImageView 时出现问题

标签 ios objective-c ios7 uitableview

我创建了一个自定义的 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 子类中这样做吗?如果是这样,您需要在 awakeFromNibprepareForReuse 中添加它。当调用 init 时, ImageView 还不存在。同时执行 self.productImageView.clipsToBounds = YES;

关于ios - 将圆角半径添加到 UITableViewCell 中的 ImageView 时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22874403/

相关文章:

ios - Swift:如何将单个键映射到多个值?

ios - 在 iOS 7 上运行 32 位 arm,在 iOS 8 上运行 64 位

ios - 无法更改 Storyboard 中 ViewController 的方向

ios - 为什么当我在平移单元格时更改 UIImageView 的图像时整个 View 会重置一秒钟?

ios - iOS 中的广告 tx 功率级别

ios - iOS 7上的ObjectAL

iphone - 为什么在加载 TableViewcontroller 时出现此错误

ios - iPhone - 获取当前点的音频幅度

ios - 如何使用 NSUnderlineStyle.PatternDot

ios - iOS 部署目标在真实设备上的神秘问题