Jacksonkr
Jacksonkr

Reputation: 32247

ios alpha mask on a scrollview

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.

Upvotes: 4

Views: 1732

Answers (3)

Jelle
Jelle

Reputation: 1034

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/

Upvotes: 1

fzwo
fzwo

Reputation: 9902

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.

Upvotes: 1

NSProgrammer
NSProgrammer

Reputation: 2396

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

Upvotes: 0

Related Questions