How to determine height of UICollectionView with FlowLayout

前端 未结 13 2079
醉话见心
醉话见心 2020-11-28 18:01

I\'ve got an UICollectionView with an UICollectionViewFlowLayout, and i want to calculate its content size (for return in intrinsicContentSiz

13条回答
  •  北海茫月
    2020-11-28 18:34

    user1046037 answer in Swift...

    class DynamicCollectionView: UICollectionView {
        override func layoutSubviews() {
            super.layoutSubviews()
            if bounds.size != intrinsicContentSize() {
                invalidateIntrinsicContentSize()
            }
        }
    
        override func intrinsicContentSize() -> CGSize {
            return self.contentSize
        }
    }
    

提交回复
热议问题