0
我的應用程序背景漸變有問題。我在viewDidLoad
中設置了MainViewController
。旋轉背景漸變xcode
CAGradientLayer *bgLayer = [BackgroundGradient blackGradient];
bgLayer.frame = self.view.bounds;
[self.view.layer insertSublayer:bgLayer atIndex:0];
每UIViewController
從MainViewController
延伸。它工作正常,但旋轉設備後,它顯示我只有一半的背景。其他是白色的。你能幫我嗎?哪裏可以成爲問題,並顯示旋轉後只有一半?
在BackgroundGradient.m
@implementation BackgroundGradient
+ (CAGradientLayer*) blackGradient {
UIColor *colorOne = [UIColor colorWithRed:0.12 green:0.13 blue:0.13 alpha:1.0];
UIColor *colorTwo = [UIColor colorWithRed:0.11 green:0.12 blue:0.13 alpha:1.0];
NSArray *colors = [NSArray arrayWithObjects:(id)colorOne.CGColor, colorTwo.CGColor, nil];
NSNumber *stopOne = [NSNumber numberWithFloat:0.0];
NSNumber *stopTwo = [NSNumber numberWithFloat:1.0];
NSArray *locations = [NSArray arrayWithObjects:stopOne, stopTwo, nil];
CAGradientLayer *headerLayer = [CAGradientLayer layer];
headerLayer.colors = colors;
headerLayer.locations = locations;
return headerLayer;
}