I am trying to create a gradient using some custom UIcolors
I created but all that shows up is white when I run the app. I created the colours in app delegate so I could use them through out the app and this is the code I used for them:
//AppDelegate.h
#import <UIKit/UIKit.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate>
+ (UIColor*)blueColor1;
+ (UIColor*)blueColor2;
+ (UIColor*)yellowColor1;
@property (strong, nonatomic) UIWindow *window;
@end
//AppDelegate.m
+ (UIColor*)blueColor1 {
return [UIColor colorWithRed:112.0 / 255.0 green:184.0 / 255.0 blue:255.0 / 255.0 alpha:1.0];
}
+ (UIColor*)blueColor2 {
return [UIColor colorWithRed:190.0 / 255.0 green:243.0 / 255.0 blue:250.0 / 255.0 alpha:1.0];
}
+ (UIColor*)yellowColor1 {
return [UIColor colorWithRed:245.0 / 255.0 green:243.0 / 255.0 blue:204.0 / 255.0 alpha:1.0];
}
And for the gradient itself I used this:
CAGradientLayer *gradient = [CAGradientLayer layer];
gradient.frame = self.view.bounds;
gradient.colors = [NSArray arrayWithObjects:(id)[AppDelegate blueColor1], (id)[AppDelegate blueColor2], (id)[AppDelegate yellowColor1], nil];
[self.view.layer insertSublayer:gradient atIndex:0];
What do I need to do to get the gradient to show?