1

There are 1 best solutions below

6
manas sharma On BEST ANSWER

UIView subclasses do not have a viewDidLoad method, instead you use the view's initializer:

class MyCell: UICollectionViewCell {

   override init(frame: CGRect) {
       super.init(frame: frame)
       layoutUI()
   }

   required init?(coder: NSCoder) {
       super.init(coder: coder)
       layoutUI()
   }

   private func layoutUI() { 
        label.layer.cornerRadius = 5
        label.backgroundColor = .blue
   }
}