ios – UITableViewCell imageView填充
2020年01月06日
作者:佚名
我想为UITableView单元格imageView设置边距或填充,我该怎么办?
使用heightForRowAtIndexPath我只能设置行高.如果我增加它,它只会放大单元格中的图像.
使用heightForRowAtIndexPath我只能设置行高.如果我增加它,它只会放大单元格中的图像.
这是我的cellForRow方法
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *cellID = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID] autorelease]; cell.textLabel.numberOfLines = 1; cell.textLabel.font = [UIFont systemFontOfSize:kSystemFontSize]; cell.accessoryType = UITableViewCellAccessoryNone; cell.textLabel.textColor = [UIColor whiteColor]; } cell.textLabel.text = [_dataArray objectAtIndex:indexPath.row]; cell.imageView.image = [UIImage imageNamed:[_imageArray objectAtIndex:indexPath.row]]; cell.backgroundColor = [UIColor clearColor]; return cell; }
目前我只知道一种方法,我可以做到这一点 – 使用photoshop或类似的程序缩小图像的图像内容,同时保持.但是这种方法需要花费很多时间,我想应该有更简单的方法来做到这一点.
解决方法
没有子类:
cell.imageView.transform = CGAffineTransformScale(CGAffineTransformIdentity,.5,.5);
根据您的情况以适当的比例更改“.5”
以上是来客网为你收集整理的ios – UITableViewCell imageView填充全部内容,希望文章能够帮你解决ios – UITableViewCell imageView填充所遇到的程序开发问题。
如果觉得来客网网站内容还不错,欢迎将来客网网站推荐给程序员好友。