Reputation: 141
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..
Upvotes: 1
Views: 1029
Reputation: 2591
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;
}
Upvotes: 1