【问题标题】:UITableView Swipe Cell's BorderUITableView 滑动单元格的边框
【发布时间】:2020-06-06 18:43:32
【问题描述】:

我在 macOS Catalina 上使用 Swift 5 和 Xcode 11.4.1。

我用了这个方法:

override func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? { //code }

使单元格可滑动。

然后,我用下面的代码使边框变圆。

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

    let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
    cell.textLabel?.text = arr[indexPath.section]
    
    cell.backgroundColor = UIColor.white
    cell.layer.borderColor = UIColor.gray.cgColor
    cell.layer.borderWidth = 1
    cell.layer.cornerRadius = 10
    cell.clipsToBounds = true

    return cell
}

取消滑动特定单元格后(在下图中,我对第二个单元格进行了滑动),圆角变为方形边框。

【问题讨论】:

    标签: ios swift xcode uitableview


    【解决方案1】:

    只需替换这些代码行:

     cell.contentView.layer.borderColor = UIColor.gray.cgColor
     cell.contentView.layer.borderWidth = 1
     cell.contentView.layer.cornerRadius = 10
     cell.contentView.clipsToBounds = true
    

    【讨论】:

    • 谢谢先生。你救了我的命! XD
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多