Hi
I have a simple application where I have a some custom views and I want to add a gradient effect in some of them with CAgradientlayer but my code doesn’t work well, my code
gradientLayer.bounds = CGRectMake(0, 0, [customer_general_view bounds].size.width, [customer_general_view bounds].size.height);
CGColorRef color1 = CGColorCreateGenericRGB(0.98, 0.98, 0.98, 1);
CGColorRef color2 = CGColorCreateGenericRGB(1, 1, 1, 1);
NSNumber *stopOne = [NSNumber numberWithFloat:0.00];
NSNumber *stopTwo = [NSNumber numberWithFloat:0.02];
NSNumber *stopThree = [NSNumber numberWithFloat:0.02];
NSNumber *stopFour = [NSNumber numberWithFloat:0.50];
NSNumber *stopFive = [NSNumber numberWithFloat:0.50];
NSNumber *stopSix = [NSNumber numberWithFloat:0.95];
NSNumber *stopSeven = [NSNumber numberWithFloat:1.00];
NSArray *locations = [NSArray arrayWithObjects:stopOne, stopTwo, stopThree, stopFour, stopFive, stopSix, stopSeven, nil];
//Package the new color pair in an array (the format required for CAGradientLayer)
NSArray *colors = [NSArray arrayWithObjects:(id) color1, color2, nil];
[gradientLayer setColors:colors];
gradientLayer.locations = locations;
//Release the colors
CGColorRelease(color1);
CGColorRelease(color2);
[customer_general_view setLayer:gradientLayer];
[customer_general_view setWantsLayer:YES];
I don’t know if i’m missing something.
I solve my problem making a subclass of NSView. In the header I wrote:
And in the implementation I wrote:
But I couldn’t solve the problem with the CAgradient layer if anyone has a answer for that it would be great