gpt4 book ai didi

ios - uitableviewcell 内的 Collection View 单元格中的图像不带圆角

转载 作者:行者123 更新时间:2023-11-28 05:38:05 25 4
gpt4 key购买 nike

我有一个表格 View ,在其中一行中,我有一个自定义单元格,它有一个带水平滚动的 Collection View 。在 Collection View 单元格中,我有我添加了圆角的图像。

img_Photo.backgroundColor = UIColor.colorFromCode(0xf2f2f2)
img_Photo.layer.cornerRadius = img_Photo.frame.height / 2
img_Photo.layer.masksToBounds = true

拐角半径首先显示如下,然后在滚动时看起来是正确的。我缺少什么来正确设置它。

我在 tableviewcell 中添加了 layoutIfNeeded

override func layoutIfNeeded() {
super.layoutIfNeeded()
collectView.frame = self.contentView.bounds
}

on first load

after scrolling

最佳答案

在您的 Collection View 单元格类中覆盖 layoutSubviews() 并在其中设置圆角半径。

关于ios - uitableviewcell 内的 Collection View 单元格中的图像不带圆角,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57955902/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com