I noticed a StackOverflow question where the author was interested in disabling the bounce effect for CollectionView. They had a method for ListView, but was now looking on how to do it for CollectionView on iOS. I put together a small sample, let me tell you what I did.
The Bounce Effect
If you have no idea what the "bounce effect" is, let me explain first. If you're on iOS and you show a scrolling control in any form or shape, when you scroll past the beginning or the end it will "bounce" back. This is also known as overscroll.
Underneath you can see this happening in a GIF.
Disabling the Bounce
In native iOS you can simply disable this behavior by setting a property
Bounces. This property is not exposed through Xamarin.Forms though. This is why we need a custom renderer to achieve this.
This custom renderer can be seen below. The
CollectionViewRenderer actually wraps a
UICollectionView object which has the
Just add this custom renderer to your iOS project, make sure that you want to use the
NoBounceRenderer name or rename it 🙂 and you should be all set.
Simply set that property to false and the bounce effect will be gone!
That's All Folks!
Nothing more to it than this. I hope you can use this whenever you need it. This custom renderer is of course very specific to this one use-case. But with custom renderers you can change anything and everything about the way Forms renders your controls.
Please reach out to me on Twitter if you liked this, or maybe have some other issue or question that you might need help with.
Header image based on People photo created by teksomolika - www.freepik.com