I'm developing an iOS app and i have a full screen UIScrollView with a UIImageView at the top and 2 UIButton in the bottom.
When the user scrolls i want to insert an animation on the image view (maybe only change the alpha parameter gradually).
The animation is correlated with the scrollview, for example, if the user scrolls the scrollview half, will be displayed only half animation.
I hope I explained myself.
How can i do this?
Use the
UIScrollViewDelegate scrollViewDidScroll:
method.https://developer.apple.com/library/ios/documentation/uikit/reference/uiscrollviewdelegate_protocol/Reference/UIScrollViewDelegate.html#//apple_ref/occ/intfm/UIScrollViewDelegate/scrollViewDidScroll:
But also check out other methods in that delegate.
So for example, you may end up with something like (or change this to your needs):
You might also want to learn from Apple engineers themselves. Check out the WWDC videos, there are many of them:
Implement the
UIScrollView
Delegate protocol and use this methodHere you can change the alpha value of your
UIImageView
by adjusting the opacity of the view's layer:That's called an implicit animation.