-3

I have those variables in collectionviewcell file and I want to change label background and cornerradius but that file doesnt have a viewdidload how can I do that . Thanks for helps.

Veysel Bozkurt
  • 53
  • 2
  • 11

1 Answers1

0

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
   }
}
manas sharma
  • 463
  • 1
  • 6
  • 8