Ita*_*mar 5 iphone user-interface objective-c uitableview
我正在尝试为分组的行设置自定义背景UITableView,我完全不知道如何实现这一点.
我试图在我的桌子上应用的表设计如下所示:

我把它切成3种细胞类型:顶部,中部和底部.如何为每个表格的单元格应用自定义背景?
小智 6
您可以在函数中将第一个,中间和最后一个单元格设置UIImageView为单元backgroundView格:
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
Run Code Online (Sandbox Code Playgroud)
检查好的(和简单的)示例:http: //www.planet1107.net/blog/tips-tutorials/custom-grouped-cell-tutorial/
在 中cellForRowAtIndexPath,检查当前行的类型,然后为其分配相应的背景。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
// Create cell
// ...
// Configure cell
switch (cellType) {
case TOP:
cell.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"top.png"]];
break;
case MIDDLE:
...
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5168 次 |
| 最近记录: |