【问题标题】:UITableViewCell separatorInsets in iOS 7iOS 7 中的 UITableViewCell separatorInsets
【发布时间】:2014-03-19 06:46:11
【问题描述】:

如何以编程方式将表格视图单元格的 separatorInsets 设置回它们的默认值?我想为某些单元格更改它们,但不是其他的。

【问题讨论】:

    标签: uitableview ios7


    【解决方案1】:

    使用以下方式:

     if (indexPath.row == {your row number}){
            cell.separatorInset = UIEdgeInsetsMake(0, 15, 0, 0);
        }
    

    在 iOS7 表格视图中默认插入 15 个分隔符,您可以使用上面的代码根据您的要求更改它。

    【讨论】:

    • 我希望有一个不涉及明确设置值的解决方案。 Apple 可能会决定在更高版本的 iOS 中更改默认值。
    • 这很糟糕,因为 separatorInsets 在 iPhone 7 Plus 上实际上是不同的。
    【解决方案2】:
    [self.tableView setSeparatorStyle:UITableViewCellSeparatorStyleSingleLine];
    

    根据文档,

    UITableViewCellSeparatorStyleSingleLine 隔板有一条横穿其宽度的线。这是默认值。适用于 iOS 2.0 及更高版本。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-08-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-02-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多