Creating a shadow for a UITableView

Will someone explain how to create one or two pixel shadows ONLY on the very last cell (in other words, I don’t need a shadow around the whole table, only the bottom cell. I'm talking about:

enter image description here

+3
cocoa-touch uitableview core-graphics
source share
2 answers

solved. Use the following code to create a very nice, subtle shadow at the bottom of your UITableViewCell . Pretending to be slightly raised from the page :)

 UIView* separatorLineView = [[UIView alloc] initWithFrame:CGRectMake(3, 49, cell.frame.size.width-26, 3)];/// change size as you need. separatorLineView.backgroundColor = shadowColor;// you can also put image here UIBezierPath *roundedShadow = [UIBezierPath bezierPathWithRoundedRect:separatorLineView.bounds byRoundingCorners:UIRectCornerBottomLeft|UIRectCornerBottomRight cornerRadii:CGSizeMake(8.0f, 8.0f)]; CAShapeLayer *newSeparatorShape = [[CAShapeLayer alloc] init]; [newSeparatorShape setPath:roundedShadow.CGPath]; separatorLineView.layer.mask = newSeparatorShape; [cell.contentView addSubview:separatorLineView]; 

Also, be sure to put this at the top of your .m file #import <QuartzCore/QuartzCore.h>

+2
source share

You can, in tableView: cellForIndexPath: set the background image of the cell to one that includes rounded corners with a shadow.

0
source share

All Articles