I want to move the height to fit the contents inside. This CollectionView after every cell has been rendered. this is screen app -> enter image description here
I want to move the height to fit the contents inside. This CollectionView after every cell has been rendered.
2
Answers
To dynamically adjust the height of your CollectionView to accommodate the content within each cell after rendering, consider integrating the "DynamicHeightCollectionView" pod. This pod, has proven to work seamlessly in similar scenarios.
To incorporate the pod into your project, follow these steps:
Add the pod to your project by including the following line in your
Podfile:
pod ‘DynamicHeightCollectionView’
Run pod install in your terminal to install the new dependency.
Utilize the DynamicHeightCollectionView class for your collection
view:
let dynamicHeightCollectionView = DynamicHeightCollectionView()
// Configure your collection view as needed
// …
By leveraging this pod, you should experience improved flexibility in adjusting the height of your CollectionView based on the content within each rendered cell. Ensure to consult the documentation provided by the pod for any additional customization options.
I think you need to check initially if collection content height is bigger then collection frame height.
Here is an example using frame, you can also do it with
NSLayoutConstraint