I have created 3 custom views in a UIViewController
. In each custom view, I have created shapes using CAShapeLayer.
These layers also contain gradient colour. Now I want to set gradient colour to custom views. When I am trying to do that, it is crashing. For first view, here is code :
//first component
self.aTimeScaleMonthView = [[TimeScaleView alloc] initWithFrame:CGRectMake(ORIGIN_X, frame.origin.y, frame.size.width-(2*ORIGIN_X), HEIGHT_OF_COMPONENT1) withStartDate:startDate endDate:endDate];
self.aTimeScaleMonthView.modeOfScale = A3TimeScaleMonth;
self.aTimeScaleMonthView.layer.borderColor = [UIColor blackColor].CGColor;
self.aTimeScaleMonthView.layer.borderWidth = BORDER_WIDTH_BOX;
CAGradientLayer *gradient = [CAGradientLayer layer];
gradient.frame = self.aTimeScaleMonthView.bounds;
gradient.colors = [NSArray arrayWithObjects:[UIColor colorWithRed:0.66 green:0.29 blue:0.22 alpha:1.0], [UIColor colorWithRed:0.62 green:0.51 blue:0.314 alpha:1.0], nil];
[self.aTimeScaleMonthView.layer insertSublayer:gradient atIndex:0];
[self addSubview: self.aTimeScaleMonthView];
Please help me.