I'm in the process of creating iPhone photo App like application.In iPhone Photo App on selecting a image -> Tapping share button -> Rotate the device to landscape, we get a selection button at the bottom of all the image items. The selection button frame gets animated when the UICollectionviewCell is scrolled I would like to achieve the same behavior in my app.Any pointers would be really helpful.
1 Answers
Use the scroll view delegate to detect when the user is scrolling. You get a scrollViewDidScroll:
event every instant the user scrolls at all. This allows you to figure out whether the button for one of the cells is being moved off the visible area of the screen. If it is, move it the other way to compensate and thus keep it on the screen.
A really useful trick is, once the cell is moving off the screen, to rejigger the button's constraints so that it is constrained to the window (or the root view). This means that it stays still while the scroll view scrolls, even though it is a subview of the cell!
Of course you also have to detect when we have scrolled so far that the button has reached the other edge of the cell, and "let go" of it - allow it to scroll with the cell once again.

- 515,959
- 87
- 875
- 1,141