CAGradientLayer *lay = [CAGradientLayer layer]; [lay setFrame:self.view.bounds]; lay.colors = @[[UIColor redColor],[UIColor blueColor]]; [self.view.layer insertSublayer:lay atIndex:0];