#pragma mark - UITableViewDelegate method
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
// Remove seperator inset
if ([cell respondsToSelector : @selector (setSeparatorInset :)]) {
[cell setSeparatorInset : UIEdgeInsetsZero ];
}
// Prevent the cell from inheriting the Table View's margin settings
if ([cell respondsToSelector : @selector (setPreservesSuperviewLayoutMargins :)]) {
[cell setPreservesSuperviewLayoutMargins : NO ];
}
// Set Your explictly cell's layout margins
if ([cell respondsToSelector : @selector (setLayoutMargins :)]) {
[cell setLayoutMargins : UIEdgeInsetsZero ];
}
}
Swift
// In viewDidLoad
tableView?.cellLayoutMarginsFollowReadableWidth = false
func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
if cell.responds(to: #selector(setter: UITableViewCell.separatorInset)) {
cell.separatorInset = UIEdgeInsets.zero
}
if cell.responds(to: #selector(setter: UIView.preservesSuperviewLayoutMargins)) {
cell.preservesSuperviewLayoutMargins = false
}
if cell.responds(to: #selector(setter: UIView.layoutMargins)) {
cell.layoutMargins = UIEdgeInsets.zero
}
}
Swift
// In viewDidLoad
tableView?.cellLayoutMarginsFollowReadableWidth = false
func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
if cell.responds(to: #selector(setter: UITableViewCell.separatorInset)) {
cell.separatorInset = UIEdgeInsets.zero
}
if cell.responds(to: #selector(setter: UIView.preservesSuperviewLayoutMargins)) {
cell.preservesSuperviewLayoutMargins = false
}
if cell.responds(to: #selector(setter: UIView.layoutMargins)) {
cell.layoutMargins = UIEdgeInsets.zero
}
}
No hay comentarios:
Publicar un comentario