birdy
birdy

Reputation: 953

UICollectionView: update flowLayout by pressing the button

I have two views. Parent view has content view which is UICollectionView and for example UIButton. How to change size (for example + 5px) of items with pressing the button?

Upvotes: 0

Views: 1261

Answers (1)

Svetoslav Bramchev
Svetoslav Bramchev

Reputation: 433

You can have variable with collection view cell height and when click button increase this height then just reload collectionView and your cell will be higher

var CELL_HEIGHT = 44

func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize {
    return CGSize(width: CELL_WIDTH, height:CELL_HEIGHT)
}

@IBAction func buttonClick(sender: AnyObject) {
    CELL_HEIGHT = CELL_HEIGHT + 5
    self.collectionView.reloadData()
}

Upvotes: 4

Related Questions