4

I know you can mask an image in ios, but can you mask a scrollview? I'm wanting to alpha mask my scrollview so that the content on the ends appears to fade out before it gets clipped by the scrollview. Is something like this possible?

FYI I have already tried work-arounds that "fake" this effect and they don't work due to a dynamic background. I need strict alpha masking on the scrollview if at all possible.

Jacksonkr
  • 31,583
  • 39
  • 180
  • 284

3 Answers3

1

You can fake this effect by laying over an image with alpha over the end of the scrollview. That way the fading effect stays in place, and the scrollView appears to fade out.

fzwo
  • 9,842
  • 3
  • 37
  • 57
  • I tried that initially, but there is an animation that passes through this area. When the animation item passes by you can tell that there is an image above the scrollview with a fade on it. Otherwise this would have worked fine. – Jacksonkr May 06 '12 at 16:42
1

You can do this nicely by using layer masking:

  • create a mask with the appropriate alpha gradient
  • add the mask to the table
  • implement the scroll delegate, to reposition the mask to the current viewport when the table gets scrolled.

It is all explained very well here: http://www.cocoanetics.com/2011/08/adding-fading-gradients-to-uitableview/

Jelle
  • 1,024
  • 10
  • 18
0

Could you implement a footer (or last cell) that has the appropriate alpha fade to give you the effect you are looking for?

NSProgrammer
  • 2,387
  • 1
  • 24
  • 27