Home  >  Q&A  >  body text

ios - UICollectionView能否通过自动约束根据内容自动改变高度

UICollectionView能否通过自动约束根据内容自动改变高度。
刚开始设置它的frame为CGRectZero,

var pictureView: UICollectionView = UICollectionView(frame: CGRectZero, collectionViewLayout: self.layout)

如里面cell个数为0,高度为0,里面cell个数为2高度为150等。

PHP中文网PHP中文网2741 days ago295

reply all(2)I'll reply

  • 怪我咯

    怪我咯2017-04-17 17:57:00

    Yes, just customize a cell

    reply
    0
  • PHPz

    PHPz2017-04-17 17:57:00

    Set the height constraint of UICollectionView in SB. Drag the constraint to the proxy class of UICollectionView in SB, and then change the value of this constraint every time data is passed in

    reply
    0
  • Cancelreply