As can be seen in the image above there is a black shadow at the bottom of the image. I want similar effect in table view.( I want shadow for every line or the seperator between the table view cells.) The shadow effect should be more on the center as can be seen above and it should fade at its extremes.. Kindly help..
Asked
Active
Viewed 1,000 times
1
-
Welcome to StackOverflow. Check the StackOverflow's help on asking questions first, please. Focus on [How to ask a good question](http://stackoverflow.com/help/how-to-ask) and [How to create a Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve), but also other [help topics](http://stackoverflow.com/help/asking) would be useful. – David Ferenczy Rogožan Nov 24 '15 at 15:28
-
2add the shadow to the UIImageView http://nscookbook.com/2013/01/ios-programming-recipe-10-adding-a-shadow-to-uiview/ – Igor Nov 24 '15 at 15:31
1 Answers
1
You can add a shadow by adding it to the view's layer (change the values to get your desired effect):
view.layer.shadowColor = [UIColor blackColor].CGColor;
view.layer.shadowOffset = CGSizeMake(0.0f, 2.0f);
view.layer.shadowOpacity = 0.5f;
view.layer.shadowRadius = 4.0f;
As you mentioned, you want to use it inside a UITableView
, then you should provide a shadowPath
as well for the best performance:
- (void)layoutSubviews
{
[super layoutSubviews];
view.layer.shadowPath = [UIBezierPath bezierPathWithRect:view.bounds].CGPath;
}

Rick van der Linde
- 2,581
- 1
- 20
- 22