I am using CAGradientLayer to create a background layer, as described in this answer to this question: Gradients on UIView and UILabels On iPhone
However when I use this code I get a exc_bad_access error with a reference to CGColorSpaceGetModel.
UILabel *headerText = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width -10, 18)];
CAGradientLayer *gradient = [CAGradientLayer layer];
gradient.bounds = headerText.bounds;
UIColor *topColor = [[UIColor alloc] initWithRed:0.5647 green:0.6235 blue:0.6667 alpha:1.0];
UIColor *bottomColor = [[UIColor alloc] initWithRed:0.7216 green:0.7569 blue:0.7843 alpha:1.0];
NSArray *gradientColors = [[NSArray alloc] initWithObjects:topColor, bottomColor, nil];
gradient.colors = gradientColors;
[headerText.layer insertSublayer:gradient atIndex:0];
Any idea what could be causing this error?