我想要一个全屏的 UITableView
。但是 UITableView
的内容应该在左边和右边有一个填充。
所以我尝试设置ContentInset
。但现在单元格与 UITableView
一样宽,并且 UITableView
水平滚动。
有没有办法说 UITableView
内容的宽度应该被水平内容插入变窄?还是我必须向所有单元格和页眉/页脚 View 添加填充?
我不想缩小 TableView 本身,因为滚动指示器应该位于屏幕的右侧而不是中间。 这里(How to set the width of a cell in a UITableView in grouped style)建议的解决方案似乎不像我喜欢的那样通用,因为单元格和页眉和页脚 View 必须知道填充(至少要维护 3 个位置而不是一个)
最佳答案
I don't want to narrow the table view itself, because the scroll indicator should stay at the right side of the screen and not in the middle.
这让你开心?
_tableView.clipsToBounds = NO;
_tableView.scrollIndicatorInsets = UIEdgeInsetsMake(0, 0, 0, -30.f);
如果您不喜欢 clipsToBounds = NO
效果,您可以将 tableView 嵌入到 clipsToBounds = YES
的容器 View 中。
关于ios - TableView ContentInset 不缩小单元格宽度/向 TableView 内容添加水平填充,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24882525/