How to adjust UIView height according to the Collection View Content Height in swift 3?

后端 未结 1 773
北荒
北荒 2021-01-26 08:32

I have a problem of adjusting the UIView height in my project. I illustrated the project.

Let me explain about my project image.
Each Orange UIView has

相关标签:
1条回答
  • 2021-01-26 08:57

    Since UITableView or UICollectionView inherit from UIScrollView they basically do not have an intrinsicContentSize.
    You have two ways to make the same height as the content size (the space that you can scroll):

    • You can subclass the collection view and override intrinsicContentSize method to return the contentSize and the sizeThatFits: method as well
    • Create a height constraint in the interface and set it as equal to the content size of the collection view.
    0 讨论(0)
提交回复
热议问题