开发者

Showing shadow in a cell inside table view

Inside a table vie开发者_运维技巧w, Is there any way to show a shadow in a specific cell? I want to show shadow in the last cell of my table view. Rest of the cells should be normal.

I am using the following code but the shadow is coming after my cell is finished. I want the shadow to be at the beginning of my cell:

[self.layer setShadowOffset:CGSizeMake(0, 1)];
[self.layer setShadowOpacity:1];
[self.layer setShadowRadius:1.0f];
[self.layer setShadowColor:[UIColor colorWithRed:50.0 green:70.0 blue:56.0 alpha:0.5].CGColor];
[self.layer setShadowPath:[[UIBezierPath bezierPathWithRect:CGRectMake(0, -44, 320.0,20)] CGPath]]; 


You can just change your cell in the -[tableView:cellForRowAtIndexPath:] method of your tableviews's datasource.

Check if the indexPath.row is the last row in your tableview. If it is not, return table view cells as usual. Otherwise, return a cell with the shadow. It is probably best to have a different reuseIdentifier for the cell with the shadow (see the docs for UITableViewCell and UITableViewDataSource for more details).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜