嗨,我正在尝试从该颜色设置为另一个视图的渐变中获取颜色。我可以设置开始和结束颜色,但不能设置角度和类型。
以下是值: 1.Startcolor:@"2b2b2b" 2.Endcolor:@"4a4a4a" 3.GradientAngle:90 4.GradientType:@"linear"
UIView *theView=[[UIView alloc] init];
theView.frame=self.view.frame;
CAGradientLayer *gradient = [CAGradientLayer layer];
gradient.frame = theView.bounds;
UIColor *startColor = [self colorwithHexString:@"2b2b2b" alpha:1];
UIColor *endColor = [self colorwithHexString:@"4a4a4a" alpha:1];
gradient.colors = [NSArray arrayWithObjects:(id)[startColor CGColor], (id)[endColor CGColor], nil];
[theView.layer insertSublayer:gradient atIndex:0];