gpt4 book ai didi

iphone - TableView 中的 imageView setFrame

转载 作者:行者123 更新时间:2023-11-29 04:55:43 26 4
gpt4 key购买 nike

我想将图像放置在位置 (10,10,60,60)。我编写了代码,但图像从角落显示。代码 [cell.imageView setFrame:CGRectMake(10,10,60,60)]; 无效。

if(indexPath.row==0)
{
NSString *filepath=[[NSBundle mainBundle]pathForResource:pro.s_image ofType:@"png"];
UIImage *image=[UIImage imageWithContentsOfFile:filepath];

//cell.imageView.contentMode = UIViewContentModeScaleAspectFit;

//[cell.imageView setContentMode:UIViewContentModeScaleAspectFit];

//[cell.imageView setFrame:CGRectMake(50,50,100,100)];

[cell.imageView setFrame:CGRectMake(10,10,60,60)];

// CGRect iframe = cell.imageView.frame;
// iframe.size.height = 100.0;
// iframe.size.width=100.0;
// cell.imageView.frame = iframe;

cell.imageView.image=image;
}

最佳答案

一种选择是子类化 UITableViewCell 并在子类中设置图像的位置。

这是一篇类似的文章,只不过他们试图自定义文本标签的位置:

iPhone UITableViewCell: repositioning the textLabel

关于iphone - TableView 中的 imageView setFrame,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8026924/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com