哇,那真是一口。 :)
我们已经在customizing the more menu (table view) in a tab bar上看到了一个很好的帖子。 .
对于我们的下一个技巧……如何向表格单元格添加背景图像?
我认为我可以在“更多 TableView ”的数据源类中重写tableView:cellForRowAtIndexPath:(有关方法,请参阅前面的链接)。唉,它只更改了每个单元格左侧和右侧图像和附件 View 下的背景。
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
// Let the original Data Source get a hold of the cell first.
UITableViewCell *cell = [originalDataSource tableView:tableView cellForRowAtIndexPath:indexPath];
// If we override the textColor, that works fine. (Commented out for now.)
//cell.textLabel.textColor = [UIColor whiteColor];
// If we override the background view … that doesn't work so well.
cell.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"cellBackground.png"]];
return cell;
}
我知道,imageNamed:是邪恶的,也许我应该创建一个背景图像并在整个过程中重复使用它(而不是分配多个UIImageView对象)。除了这些东西,还有什么想法吗? (我也尝试调整 textLabel 的背景颜色,但无济于事......除非我在那里做错了什么。)
最佳答案
Here就是答案...
添加代码
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
MoreTableViewDataSource方法
关于iphone - UITabBarController 更多NavigationController 表格单元格背景图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1556430/