【发布时间】:2018-06-04 14:04:47
【问题描述】:
我有一个UITableViewCell,其中包含一个UIImageView。
图像视图应该是一个圆形,所以我将cornerRadius设置为它的高度的一半。问题是如果图像不够大(图像视图的宽度/高度约束,而不是图像本身),则无法正确舍入。如果我增加约束,一切都会正常。
图像是正方形,图像视图也有 1:1 的比例约束。 知道问题出在哪里吗?
我打电话给awakeFromNib:
private func setUpCellDesign() {
profileImageView.layer.cornerRadius = profileImageView.frame.height / 2
profileImageView.clipsToBounds = true
mainView.layer.cornerRadius = 15
}
我注意到即使我在单元格中添加其他元素并尝试以相同的方式圆角(例如带有圆角的按钮),它也无法正常工作。
【问题讨论】:
-
你有限制吗?设置
maskToBounds = true
标签: ios swift autolayout