dra*_*sea 0 uitableview ios swift
我刚刚买了一本书并在Swift中学习编程IOS.我想创建一个像Snapchat这样的表视图列表:

然后我将UITableView的所有约束设置为
0:
但是,桌子左边还有一个余量,为什么呢?

单击后在界面构建器中搜索分隔符插入 UITableView

并将其更改为自定义.现在您可以将Left Inset设置为0

在 viewDidLoad
[tableView setSeparatorInset:UIEdgeInsetsZero];
Run Code Online (Sandbox Code Playgroud)
添加以下代码 cellForRowAtIndexPath:
if ([cell respondsToSelector:@selector(preservesSuperviewLayoutMargins)]){
cell.layoutMargins = UIEdgeInsetsZero;
cell.preservesSuperviewLayoutMargins = false;
}
Run Code Online (Sandbox Code Playgroud)
if ([UITableView instancesRespondToSelector:@selector(setLayoutMargins:)]) {
[[UITableView appearance] setLayoutMargins:UIEdgeInsetsZero];
[[UITableViewCell appearance] setLayoutMargins:UIEdgeInsetsZero];
[[UITableViewCell appearance] setPreservesSuperviewLayoutMargins:NO];
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
264 次 |
| 最近记录: |