1
我有一個自定義UITableViewCell
與自我大小和UILabel
和陰影。自動調整大小UITableViewCell陰影關閉
class CustomCell: UITableViewCell {
@IBOutlet weak var titleLabel: UILabel!
@IBOutlet weak var cellBackgroundView: UIView!
@IBOutlet weak var creationDateLabel: UILabel!
override func layoutSubviews() {
super.layoutSubviews()
self.cellBackgroundView.layer.cornerRadius = 12
self.cellBackgroundView.layer.shadowColor = UIColor.black.withAlphaComponent(1.0).cgColor
self.cellBackgroundView.layer.shadowOffset = CGSize.zero
self.cellBackgroundView.layer.shadowRadius = 9
self.cellBackgroundView.layer.shadowOpacity = 0.8
self.cellBackgroundView.layer.shadowPath = UIBezierPath(rect: self.cellBackgroundView.bounds).cgPath
self.cellBackgroundView.layer.masksToBounds = false
self.cellBackgroundView.layer.shouldRasterize = true
self.cellBackgroundView.layer.rasterizationScale = UIScreen.main.scale
}
}
我試圖實現layoutSubviews()
,cellForRowAt: indexPath
和willDisplay cell
這個代碼,但它始終關閉,而不是居中:
編輯:它在我開始在tableView中滾動時起作用。
編輯2:這是應該的樣子:
謝謝!
什麼是「永遠關閉而不居中」? – Koen
@Koen你可以在我附上的圖片中看到它。陰影應該直接在單元格下面。我會張貼它應該看起來的照片。 – kuklis