[英]Set image on tableView Cell size
我有tableView
Cell大小,需要在tableView cell
上设置图像。但是,未设置图像定义cell大小(以下代码存储到tableView
Cell size中,存储了cellSize
变量)。 我的代码是...,
CGRect cellSize = [tableView rectForRowAtIndexPath:indexPath];
cell.imageView.frame = cellSize;
cell.imageView.image = [UIImage imageNamed:@"logo_black.png"];
图像中的上述代码未在tableView Cell.
properly
设置图像tableView Cell.
那么,如何在TableView
Cell
上设置图像?
如果您试图说您在每个单元格中设置的图像没有显示在正确的位置,那么您可以尝试执行以下操作:
首先创建一个原型单元,然后将UIImageView
放置在所需单元中的正确位置,然后转到UIImage
的scale属性,并记下坐标...
代替
CGRect cellSize = [tableView rectForRowAtIndexPath:indexPath];
cell.imageView.frame = cellSize;
这可以编写如下代码:
cell.imageView.frame = CGRectMake(x,y,width,height);
例如
CGRectMake(0,0,20,20)
CGRect cellSize = cell.frame;
cell.imageView.frame = cellSize;
试试这个代码:
UIView *bgView = [[UIView allow ] init];
bgView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageName:@"imgName"]];
cell.selectedBackgroundView = bgView;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.