1

How can I apply gradient on multiple table cells so it will appear as one view using Gradient layer. I don't want as follows instead both cells should look as one view with this layer. Is it possible? I show following cells in multi level table hierarchy.

enter image description here

Vishwanath Deshmukh
  • 619
  • 1
  • 10
  • 32
  • you could either use a background image with the gradient or you could create a view with color gradient. – Teja Nandamuri Apr 19 '18 at 19:53
  • Possible duplicate of [Programmatically create a UIView with color gradient](https://stackoverflow.com/questions/23074539/programmatically-create-a-uiview-with-color-gradient) – Teja Nandamuri Apr 19 '18 at 19:53

1 Answers1

1

Maybe this will help:-

Set your Cell Color as

cell.backgroundColor=[UIColor clearColor];

Then:-

UIView *view = [[UIView alloc] initWithFrame:self.tableview.frame];
CAGradientLayer *gradient = [CAGradientLayer layer];
gradient.frame = view.bounds;
gradient.colors = @[(id)[UIColor blackColor].CGColor,(id)[UIColor whiteColor].CGColor];
[view.layer insertSublayer:gradient atIndex:0];
self.tableview.backgroundView=view;
tryKuldeepTanwar
  • 3,490
  • 2
  • 19
  • 49