Domanda

I don't know what this effect is called. Fancy uses it in its app. It works like this.

  • You have an image at the top of a scrollview.
  • Drag down and the image gets zoomed to fill the extra top space, so its top edge always remains at the top edge of this scrollview
  • release your finger and it bounces back

Please give me some idea on how to build this effect. Thanks!

È stato utile?

Soluzione

There are many open source implementations of this, such as:

The basic idea behind these is to have an imageview as a subview of the scrollview. When scrolling, you monitor the content offset of the scrollview, and when you reach a certain threshold, you start increasing the image view's height. If you set the image view's contentMode to UIViewContentModeScaleAspectFill, you will get the effect you want.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top