iPad split view + dragging one of the windows to change size + collection view cells' corner radius issues

custom cell has the below and invalidate layout in viewWillTransition

visual debugger indicates width = height; don’t know why it renders an ellipse looking shape

override var bounds: CGRect {
  didSet {
   self.layoutIfNeeded()
  }
}

override func layoutSubviews() {
  super.layoutSubviews()
  let radius = self.categoryImageBackground.frame.height / 2
  self.categoryImageBackground.layer.cornerRadius = radius
}

what should I be looking into?

@lganti Do you still have issues with this?

1 Like

Resolved, thanks for asking

Solution - play around with overriding bounds and layoutSubviews

  override var bounds: CGRect {
    didSet {
      self.layoutIfNeeded()
    }
  }
  
  override func awakeFromNib() {
    super.awakeFromNib()
    self.categoryImageBackground.layer.masksToBounds = true
  }
  
  override func layoutSubviews() {
    super.layoutSubviews()
    self.setup()
  }
  
  private func setup() {
    let radius = self.categoryImageBackground.frame.width / 2
    self.categoryImageBackground.layer.cornerRadius = radius
  }
1 Like

@lganti Thank you for sharing your solution - much appreciated!

1 Like