Chris
Chris

Reputation: 312

Floating UIButton over UICollectionView

I have a UIButton, which is fixed in position, over a UICollectionView, not part of the actual UICollectionView view hierarchy.

Is there a way I am able to, on vertical scroll of the UICollectionView, to dynamically adapt the scroll length where the last row of the UICollectionView always appears above the floating button?

Haven't found anything to reference and am admittedly lost on implementation. Hope for any thoughts..

Below is the desired functionality:

enter image description here

Upvotes: 2

Views: 785

Answers (2)

creeperspeak
creeperspeak

Reputation: 5521

You can make it so that your UICollectionView scrolls above your button by setting a contentInset to account for the height of your button (plus the buffer above and below the button. That could look something like this:

collectionView.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: button.bounds.size.height + buffer, right: 0)

"buffer" is a placeholder for whatever you want to add to account for the space above and below the button.

Upvotes: 3

Christophe Prat
Christophe Prat

Reputation: 196

If I understood your problem, you could do something like that:

yourButton.zPosition = 100

And your button should appear above your collection view.

Upvotes: 0

Related Questions