這裏我使用此代碼給出漸變效果,但根本沒有獲得效果。添加CAGradient圖層但無法獲得漸變效果
CAGradientLayer *layer2 = [CAGradientLayer layer];
NSArray *gradientColors = [NSArray arrayWithObjects:(id)[self colorWithHexString:@"3eb79d"].CGColor,(id)[self colorWithHexString:@"3fb65c"].CGColor,(id)[self colorWithHexString:@"3cb7da"].CGColor, nil];
[layer2 setColors:gradientColors];
[layer2 setFrame:cell.userBackgroundView.layer.frame];
[cell.userBackgroundView.layer insertSublayer:layer2 atIndex:0];
cell.userBackgroundView.clipsToBounds = YES;