I have a CAGradientLayer inserted to the bottom of this small detail view that pops up at the bottom of the app. As you can see, I've set the colors from white to clear, but there's this strange gray tint that is showing up. Any ideas?
// Set up detail view frame and gradient
[self.detailView setFrame:CGRectMake(0, 568, 320, 55)];
CAGradientLayer *layer = [CAGradientLayer layer];
layer.frame = self.detailView.bounds;
layer.colors = [NSArray arrayWithObjects:(id)[UIColor whiteColor].CGColor, (id)[UIColor clearColor].CGColor, nil];
layer.startPoint = CGPointMake(1.0f, 0.7f);
layer.endPoint = CGPointMake(1.0f, 0.0f);
[self.detailView.layer insertSublayer:layer atIndex:0];
Here is the problematic view:
Swift 3 Syntax,
As many, I still got a gray colour despite using a clear white.
So I changed my approach and went for a mask rather than a gradient. End result is the same, well, better, since this one works in all situations, not just if you got a suitable background.
I did not try this code with IB, but hopefully it works as well. Just set
backgroundColor
and you are good to go.clearColor has a black color channel with an alpha of 0, so I had to use
and it works fine.
Worth pointing out that any other colour will work like this... using a combination of the two answers above....
Objective C
Swift 3
In Swift This worked for me,