Search code examples
swiftlayoutuilabelcelluicollectionviewcell

Multiline UILabel in uicollectionViewCell wrong height


I insert a multi-line label inside the cell, the cell is not sized correctly. When I use it as a single line label, it's fine, but when I use multiple, the height is wrong. Even though I used SizeToFit() I couldn't find the solution. I need to use Cell i automatic size. When I scroll, the problem is fixed, but there is wrong on the first boot. Any suggestions what can I do?

wrong cell state after scrolling


Solution

  • The problem was solved, I needed to add a contentView inside the cell and set translatesAutoresizingMaskIntoConstraints to false. Thanks for answers