Advertisement
Guest User

Untitled

a guest
Apr 20th, 2014
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  2.  
  3. static NSString *cellIdentifier = @"cell";
  4. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"myTableViewCell" forIndexPath:indexPath];
  5.  
  6. cell.layer.shouldRasterize = YES;
  7. cell.layer.rasterizationScale = [UIScreen mainScreen].scale;
  8. cell.layer.shadowColor = [[UIColor blackColor] CGColor];
  9. cell.layer.shadowOffset = CGSizeMake(0.0f, 0.0f);
  10. cell.layer.shadowRadius = 1.0f;
  11. cell.layer.shadowOpacity = 1.0f;
  12.  
  13. CGPathRef shadowPath = [UIBezierPath bezierPathWithRect:cell.bounds].CGPath;
  14. cell.layer.shadowPath = shadowPath;
  15.  
  16. return cell;
  17. }
  18.  
  19. - (UIView*)shadowWithRect:(CGRect)rect {
  20. UIView* v = [[UIView alloc] initWithFrame:rect];
  21. CAGradientLayer *gradient = [CAGradientLayer layer];
  22. gradient.frame = v.bounds;
  23. gradient.colors = [NSArray arrayWithObjects:(id)[[UIColor blackColor] CGColor], (id)[[UIColor clearColor] CGColor], nil];
  24. [v.layer insertSublayer:gradient atIndex:0];
  25. return v;
  26. }
  27.  
  28. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  29. static NSString *cellIdentifier = @"shadowCell";
  30. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier forIndexPath:indexPath];
  31. [cell addSubview:[self shadowWithRect:cell.bounds]];
  32. return cell;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement