gpt4 book ai didi

ios - UITableViewCell 的 accessoryView 中的多个图像

转载 作者:行者123 更新时间:2023-11-29 01:03:56 27 4
gpt4 key购买 nike

我正在尝试在尺寸相同的 24x24 单元格中显示多个图像。我把它们放在这样的循环中:

cell!.accessoryView = UIView()
for url in arrURL {
cell!.accessoryView?.addSubview(UIImageView(image: UIImage(named: "ic_play_circle_outline")))
}
cell!.accessoryView?.frame = CGRectMake(0, 0, 24 * CGFloat(arrURL.count), 24)

但不幸的是,它只显示一张图像,并且后面存在用于剩余图像的空白空间。这是布局:

table cell

播放图标右侧有一个空白区域。知道为什么会这样吗?

最佳答案

根据@EugeneZhenyaGordin 的评论,我尝试将框架提供给 subview 并且它有效。这是我的示例代码:

cell!.accessoryView = UIView()
var i = 0
for url in arrURL {
let myView = UIImageView(image: UIImage(named: "ic_play_circle_outline"))
myView.frame = CGRectMake(i>0 ? 24 * CGFloat(i) : 0, 0, 24, 24)
cell!.accessoryView?.addSubview(myView)
i+=1
}
cell!.accessoryView?.frame = CGRectMake(0, 0, 24 * CGFloat(arrURL.count), 24)

这是我的布局:

enter image description here

关于ios - UITableViewCell 的 accessoryView 中的多个图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36653538/

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