I'm trying to use CAGradientLayer to fade foreground controls against the background textured view. So in a nutshell, I have a view with the bg color as scrollViewTexturedBackgroundColor. I have a view on top of that, whose contents I'd like to fade at the border into the background view's color.
CAGradientLayer* gradient = [CAGradientLayer layer];
gradient.frame = self->scrollableCanvas.bounds;
gradient.colors = [NSArray arrayWithObjects:(id)[[UIColor scrollViewTexturedBackgroundColor] CGColor], (id)[[UIColor scrollViewTexturedBackgroundColor] CGColor], nil];
[gradient setStartPoint:CGPointMake(0.90, 1)];
[gradient setEndPoint:CGPointMake(1, 1)];
[[self->scrollableCanvas layer] addSublayer:gradient];
[[self->scrollableCanvas layer] setMasksToBounds:YES];
Unfortunately, CAGradientLayer doesn't seem to support UIColors as pattern images.
any ideas how I can achieve a simple border fade effect for the subview?
thanks
I made a category on UILabel that adds gradient at the end of the label using Max's answer.
If you need, here it is:
But you should use your own colors. And use this define:
You can use a little trick: