gpt4 book ai didi

ios - UITableView左右填充

转载 作者:可可西里 更新时间:2023-11-01 04:17:08 26 4
gpt4 key购买 nike

我有表格 View 。在其中我有部分,每个部分只有一行。我使用这些部分,以便我可以控制具有标题高度的行之间的空间。我想向 UITableView 添加填充,以便我可以将 cells/sections 与设备的边缘隔开。间距需要具有 UITableView 背景的颜色。

最佳答案

子类 UITableviewCell 并覆盖它的 setFrame 方法,

- (void)setFrame:(CGRect)frame {
frame.origin.x += inset;
frame.size.width -= 2 * inset;
[super setFrame:frame];
}

因此,它将从左侧和右侧填充两个像素。您可以根据需要更改它。

您可以使用 contentInset 但它仅适用于垂直间距(顶部和底部)。你应该像上面提到的那样设置单元格的框架来设置水平间距。

你可以拿this answerthis answer作为引用。

希望这会有所帮助:)

关于ios - UITableView左右填充,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37542185/

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