如果UIView
您执行以下操作:
CAGradientLayer *layer = [CAGradientLayer layer];
layer.colors = [NSArray arrayWithObjects:(id) [UIColor colorWithRed:0 green:0 blue:0.1 alpha:1].CGColor,[UIColor colorWithRed:0.3 green:0.3 blue:0.74 alpha:1].CGColor, nil];
layer.frame=CGRectMake(0, 0, self.frame.size.width,self.frame.size.height);
[self.layer insertSublayer:layer atIndex:0];
然后将drawRect
在此渐变之上执行自定义绘图吗?drawRect
会影响视图的实际背景,还是完全不同的图层?如果视图的背景颜色clearColor
仍然drawRect
显示?