【问题标题】:How to set UITableViewCell corner radious for top and bottom cell (not for all the cell) in swift如何快速设置顶部和底部单元格(不是所有单元格)的 UITableViewCell 角半径
【发布时间】:2021-07-04 09:58:33
【问题描述】:

您能否告诉我,如何为顶部和底部单元格而不是所有单元格添加自定义 UITableViewCell 的圆角半径。请找到设计屏幕以供参考。

【问题讨论】:

    标签: ios swift5 xcode12


    【解决方案1】:

    将您的表格视图样式设置为 .insetGrouped,从 iOS 13 开始可用。

    【讨论】:

      【解决方案2】:

      这里是圆角的代码 sn-p。

      if indexPath.row == 0
                  {
                      cell.baseView.layer.cornerRadius = 10
                      cell.baseView.layer.maskedCorners = [.layerMinXMinYCorner, .layerMaxXMinYCorner]
                     
                  }
      
                  if indexPath.row == tableView.numberOfRows(inSection: indexPath.section) - 1
                  {
                      cell.baseView.layer.cornerRadius = 10
                      cell.baseView.layer.maskedCorners = [.layerMinXMaxYCorner, .layerMaxXMaxYCorner]
                      
                  }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-01-07
        • 1970-01-01
        • 1970-01-01
        • 2021-03-02
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多