テーブル ビュー コントローラーの次のコードでは、「ストック」カラーを使用すると[UIColor blueColor]
問題なく動作しますが、RGBA 値を使用してカスタム カラーを作成しようとすると、恐ろしく失敗し、真っ黒以外は何も描画されません。
これは、ARC が CGColorRef を使用する前に割り当てを解除しているためですか? これをカスタムカラーで動作させるにはどうすればよいですか?
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
[cell setBackgroundColor:[UIColor clearColor]];
CAGradientLayer *selectedGrad = [CAGradientLayer layer];
selectedGrad.frame = cell.bounds;
UIColor* colorOne = [UIColor blueColor];//[UIColor colorWithRed:96/255 green:157/255 blue:227/255 alpha:1];
UIColor* colorTwo = [UIColor greenColor];//[UIColor colorWithRed:54/255 green:123/255 blue:201/255 alpha:1];
NSArray* colors = [NSArray arrayWithObjects:(id)colorOne.CGColor, colorTwo.CGColor, nil];
selectedGrad.colors = colors;
selectedGrad.locations = [NSArray arrayWithObjects:@(0.0), @(1.0), nil];
[cell setSelectedBackgroundView:[[UIView alloc] init]];
[cell.selectedBackgroundView.layer insertSublayer:selectedGrad atIndex:0];
}