显示在桌视图里面的一个细胞的阴影 [英] Showing shadow in a cell inside table view

查看:149
本文介绍了显示在桌视图里面的一个细胞的阴影的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在表格视图中,有没有办法在特定单元格中显示阴影?我想在表格视图的最后一个单元格中显示阴影。其余的单元格应该是正常的。

Inside a table view, 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]]; 


推荐答案

您只需更改<$ c中的单元格即可$ c> - [tableView:cellForRowAtIndexPath:] tableviews数据源的方法。

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

检查 indexPath.row 是否是tableview中的最后一行。如果不是,则像往常一样返回表格视图单元格。否则,返回带阴影的单元格。对于带阴影的单元格,最好有一个不同的reuseIdentifier(有关更多详细信息,请参阅UITableViewCell和UITableViewDataSource的文档)。

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).

这篇关于显示在桌视图里面的一个细胞的阴影的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆