【发布时间】:2017-11-22 10:22:21
【问题描述】:
这是我的代码:
override func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
let whiteRoundedView : UIView = UIView(frame: CGRect(x: 10, y: 8, width: self.view.frame.size.width - 20, height: 140))
whiteRoundedView.layer.backgroundColor = CGColor(colorSpace: CGColorSpaceCreateDeviceRGB(), components: [1.0, 1.0, 1.0, 0.9])
whiteRoundedView.layer.masksToBounds = false
whiteRoundedView.layer.cornerRadius = 2.0
whiteRoundedView.layer.shadowOffset = CGSize(width: -1, height: 1)
whiteRoundedView.layer.shadowOpacity = 0.2
whiteRoundedView.layer.borderWidth = 0.5
whiteRoundedView.layer.borderColor = UIColor.orange.cgColor
cell.contentView.backgroundColor = UIColor.clear
cell.contentView.addSubview(whiteRoundedView)
cell.contentView.sendSubview(toBack: whiteRoundedView)
cell.accessoryType = .disclosureIndicator
cell.clipsToBounds = true;
}
每个单元格都从底部切掉,没有显示完整的单元格结构。
有什么想法吗?
【问题讨论】:
-
如果图片没有显示,请告诉我。我是新来的。因此,如果您需要这方面的更多信息,请告诉我。
-
你试过增加单元格的高度吗?
-
降低
whiteRoundedView的高度或增加单元格内容视图的高度。 -
这个屏幕截图来自模拟器?或真实设备@GauravRathi
-
@byJeevan:它成功了,谢谢。我在初始化时将 whiteRoundedView 的高度降低到 40/
标签: ios uitableview cell tableviewcell