swift - 如何获取单元格之间的距离(上、下、左、右)

标签 swift

Swift

我想添加单元格之间的距离(顶部和底部)以及单元格与表格 View 墙壁之间的距离(左、右):我需要使用 UIEdgeInset 来完成此操作,而不是通过将 headerView 添加到单元格:

最佳答案

//UITableViewCell 子类内部

override func layoutSubviews() {
    super.layoutSubviews()

    contentView.frame = contentView.frame.inset(by: UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 10))
}

关于swift - 如何获取单元格之间的距离(上、下、左、右),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57025746/

相关文章:

ios - NSAttributedString 如何使用 NSParagraphStyle 设置文本行居中对齐

ios - Swift - 转换 AutoreleasingUnsafeMutablePointer<AnyObject?> 值

ios - 将 [Float] 转换为 [CGFloat] 的快速方法?

Swift:如何在变量中保存泛型类型的任何可能实例

xcode - 将 Stripe 和 PaymentKit 集成到 Swift 时出现 Apple Mach-O 链接器错误

swift - 由于未捕获的异常 'RLMException' 而终止应用程序,原因 : 'Index 0 is out of bounds (must be less than 0).' Swift

timer - 调用中的额外参数 'selector' - NSTimer scheduledTimerWithTimeInterval

swift - 从字符串中获取数字字符

ios - 从 View 中心向右动画 UIButton 的约束

ios - 如何过滤 Google Places API 自动完成数据以获取国家/地区和州