如何在 iOS 7 上修复 UITableView 分隔符?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18773239/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to fix UITableView separator on iOS 7?
提问by Dmitry
UITableView draws with ragged lines on iOS 7:
UITableView 在 iOS 7 上用参差不齐的线条绘制:
How to fix it? The line between cells should be on the full width of the screen.
如何解决?单元格之间的线应该在屏幕的整个宽度上。
回答by s1m0n
UITableView
has a property separatorInset
. You can use that to set the insets of the table view separators to zero to let them span the full width of the screen.
UITableView
有一个属性separatorInset
。您可以使用它来将 table view 分隔符的 insets 设置为零,让它们跨越屏幕的整个宽度。
[tableView setSeparatorInset:UIEdgeInsetsZero];
Note:If your app is also targeting other iOS versions, you should check for the availability of this property before calling it by doing something like this:
注意:如果您的应用程序还针对其他 iOS 版本,您应该在调用它之前通过执行以下操作检查此属性的可用性:
if ([tableView respondsToSelector:@selector(setSeparatorInset:)]) {
[tableView setSeparatorInset:UIEdgeInsetsZero];
}
回答by Tarek Hallak
This is default by iOS7 design. try to do the below:
这是 iOS7 设计的默认设置。尝试执行以下操作:
[tableView setSeparatorInset:UIEdgeInsetsMake(0, 0, 0, 0)];
You can set the 'Separator Inset' from the storyboard:
您可以从情节提要中设置“分隔符插入”: