我正在嘗試將特定漸變的顏色添加到表視圖的每個單元格中。到目前爲止,我所做的一切都是爲每個單元設置漸變。我發現了另一篇貼近我的帖子,但是通過確定行數並根據行號是否匹配給出了某種顏色,僅交替設置了兩種顏色。這裏是link。 這是我用於每個單元格的梯度的代碼;我如何將漸變的每種顏色歸於單元格?如何將漸變的顏色添加到TableView的每個單元格(或行)?
CAGradientLayer *grad = [CAGradientLayer layer];
grad.frame = cell.bounds;
grad.colors = [NSArray arrayWithObjects:(id)[[UIColor colorWithRed:252/255.f green:135/255.f blue:208/255.f alpha:1] CGColor], (id)[[UIColor colorWithRed:253/255.f green:91/255.f blue:105/255.f alpha:1] CGColor], nil];
[cell setBackgroundView:[[UIView alloc] init]];
[cell.backgroundView.layer insertSublayer:grad atIndex:0];
謝謝!
你有解決方案http://stackoverflow.com/questions/30478975/how-to-set-multiple-gradient-colour-in-uitableviewcell-using-cagradientlayer-in –