gpt4 book ai didi

ios - 需要有关 UITableViewCell SeparatorInset 的帮助

转载 作者:行者123 更新时间:2023-11-29 12:25:41 26 4
gpt4 key购买 nike

1> 我的 tableview 中有 UITableViewCellUITableViewCell subclass cell。在 UITableViewCell 子类单元格 上设置 SeparatorInset 不起作用?但是如果我在 UITableViewCell 上设置它就可以正常工作。

2> 关于 SeparatorInset 的 Apple 文档说:

You can use this property to add space between the current cell’s contents and the left and right edges of the table. Positive inset values move the cell content and cell separator inward and away from the table edges. Negative values are treated as if the inset is set to 0.

Only the left and right inset values are respected; the top and bottom inset values are ignored. The value assigned to this property takes precedence over any default separator insets set on the table view.

一个。如果我在 UITableViewCell 上设置 [cell setSeparatorInset:UIEdgeInsetsMake(0, 100, 0, 0)]; 它会将内容向右推

但是在 UITableViewCell 上设置 [cell setSeparatorInset:UIEdgeInsetsMake(0, 0, 0, 100)]; 只会将分隔符推向左侧而不是内容,为什么?

最佳答案

1)

UITableViewCell 中,您有无法直接编辑的 subview (标题、附件 View 等)。 separatorInset 使您能够调整这些 subview 的位置(换句话说,separatorInset 在这些 subview 的位置计算期间被考虑在内)。

在自定义 UITableViewCell 子类中,您定位自己的 subview ,因此除非您在计算它们的位置时特别考虑 separatorInset,否则它没有任何效果。

2)

separatorInset 不会将内容“推”到左/右,而是将(虚拟)插图添加到它们所在的容器中。所以如果例如您只有标题不会拉伸(stretch)到单元格的全宽 (-100) 添加右插图后您不会看到任何差异。

关于ios - 需要有关 UITableViewCell SeparatorInset 的帮助,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29227372/

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