我在 UITableView
中有一个单元格,它使用 colorWithPatternImage
将图像作为背景。我想在此图像上设置一种模式以适合单元格,即 UIViewContentModeScaleAspectFill
等。(我将仔细研究并找到最适合我使用的模式)
这是我的代码:
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath
*)indexPath
{
if((indexPath.row)==1)
cell.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"homeScreen-buttons.jpg"]];
}
那么我该如何编辑我的代码来添加我需要的东西呢?谢谢
最佳答案
您可以设置单元格层的内容
,试试这个:
cell.layer.contents = (id)[UIImage imageNamed:@"homeScreen-buttons.jpg"].CGImage;
关于ios - 单元格背景图像模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30794735/