Your question turned out to be the best source I could find on the main problem, so I decided to post my solution here.
If you add a mask directly to the scroll view, you will end applying the mask to the content itself for any reason - i. e. Transparency does not change when scrolling. As suggested by other posts, I put a gradient in the view (or rather, containing) the scroll view. As a result, scrollContainer is a UIViewObject whose only subordinate object is the scroll view in question.
This mask is configured to scroll left and right. You can change it from top to bottom by manipulating the properties of the start and end points of the gradient.
One downside is that it will also copy the scroll bar indicator. Since my script is not needed, this is acceptable, but your mileage may vary.
CAGradientLayer *gradient = [CAGradientLayer layer]; gradient.frame = scrollView.bounds; gradient.colors = [NSArray arrayWithObjects: (id)[[UIColor colorWithWhite:0 alpha:0] CGColor], (id)[[UIColor colorWithWhite:0 alpha:1] CGColor], (id)[[UIColor colorWithWhite:0 alpha:1] CGColor], (id)[[UIColor colorWithWhite:0 alpha:0] CGColor], nil]; gradient.locations=[NSArray arrayWithObjects: [NSNumber numberWithFloat:0], [NSNumber numberWithFloat:.1], [NSNumber numberWithFloat:.9], [NSNumber numberWithFloat:1], nil]; gradient.startPoint=CGPointMake(0, .5); gradient.endPoint=CGPointMake(1, .5); [scrollContainer.layer setMask:gradient];
Ronlugge
source share