self.layer = [CAGradientLayer layer];
self.layer.frame = CGRectMake(0, 100, self.view.frame.size.width, 300);
self.layer.opacity = 0.5;
self.layer.colors = @[(id)[UIColor redColor].CGColor,(id)[UIColor greenColor].CGColor,(id)[UIColor blueColor].CGColor];
self.layer.locations = @[@0.2,@0.5,@0.8];
self.layer.startPoint = CGPointMake(0, 0);
self.layer.endPoint = CGPointMake(1, 0);
[self.view.layer addSublayer:self.layer];