ios – UITableViewCell imageView填充

ios – UITableViewCell imageView填充,第1张

概述我想为UITableView单元格imageView设置边距或填充,我该怎么办? 使用heightForRowAtIndexPath我只能设置行高.如果我增加它,它只会放大单元格中的图像. 这是我的cellForRow方法 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPa 我想为UItableVIEw单元格imageVIEw设置边距或填充,我该怎么办?
使用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填充所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1109132.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-29
下一篇 2022-05-29

发表评论

登录后才能评论

评论列表(0条)

保存