I have a background gradient that draws beautifully when the screen is initially displayed in portrait mode. However, when the device is turned into landscape mode, the right 40% of the screen is black (i.e. the Background is not drawn on the part of the screen that was not previously drawn). I do not know how to get a background for redrawing to fill the entire screen.
Can someone tell me what I am doing wrong? Thank!
Here's what it looks like when initially drawn.

And now it looks like when I turn it:

Here is the code for my background gradient class:
#import "BackgroundGradient.h"
@interface BackgroundGradient()
@property (strong, nonatomic) UIView *view;
@end
@implementation BackgroundGradient
- (id) initWithView:(UIView *) view
{
if (!_view)
_view = view;
return self;
}
- (void) makeGradient
{
UIColor *darkOp = [UIColor colorWithRed:(193.0 / 255.0) green:(215.0 / 255.0) blue:(46.0 / 255.0) alpha: 1];
UIColor *lightOp = [UIColor colorWithRed:(222.0 / 255.0) green:(233.0 / 255.0) blue:(143.0 / 255.0) alpha: 1];
CAGradientLayer *gradient = [CAGradientLayer layer];
gradient.colors = [NSArray arrayWithObjects:
(id)darkOp.CGColor,
(id)lightOp.CGColor,
(id)darkOp.CGColor,
nil];
gradient.startPoint = CGPointMake(0.5, 0.0);
gradient.endPoint = CGPointMake(0.5, 1.0);
gradient.frame = self.view.bounds;
[self.view.layer insertSublayer:gradient atIndex:0];
gradient.locations = [NSArray arrayWithObjects:
[NSNumber numberWithFloat:0.0f],
[NSNumber numberWithFloat:0.7],
[NSNumber numberWithFloat:0.9],
nil];
}
@end
And finally, this is how I create the background object:
- (void)viewDidLoad
{
[super viewDidLoad];
self.background = [[BackgroundGradient alloc] initWithView:self.view];
[self.background makeGradient];
}
EDIT: I added the following code and enabled updates for start and end points (above):
- (void) willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
[self.background makeGradient];
}
, , . , - . , , . , .
