Ios 更改图像属性UITableView Swift

Ios 更改图像属性UITableView Swift,ios,swift,uitableview,uiimageview,Ios,Swift,Uitableview,Uiimageview,两者似乎都没有区别 当图像从URL在线加载时,它将采用其原始大小 我省略了用于异步图像下载的代码,因为我认为这里也存在同样的问题。如果不让我知道。谢谢 您需要在code或Interface Builder中设置imageView的contentmode,然后,一旦你这样做了,你需要使用cell.imageView?.clipsToBounds=true你应该将UIImageView的模式属性设置为方面匹配在单元格中显示图像。我试过cell.imageView?.contentMode=.scal

两者似乎都没有区别

当图像从URL在线加载时,它将采用其原始大小


我省略了用于异步图像下载的代码,因为我认为这里也存在同样的问题。如果不让我知道。谢谢

您需要在code或Interface Builder中设置
imageView
contentmode
,然后,一旦你这样做了,你需要使用
cell.imageView?.clipsToBounds=true
你应该将
UIImageView
模式
属性设置为方面匹配在单元格中显示图像。

我试过
cell.imageView?.contentMode=.scalespectfill
。。。我也不想设置特定的宽度、高度、x、y和alpha值。这可能吗?请再次阅读@GregoryPeck,我写了Fit和not Fill。结果不同。你能举个例子吗。。。我尝试了
cell.imageView?.contentMode=.ScaleAspectFill
,但什么也没做`您设置了
clipstobunds
属性吗?您可能还需要
导入QuartzCore
我还想设置特定的宽度、高度、x、y和alpha值。这可能吗?也许你应该更详细地解释一下你想做什么,也许一些屏幕截图或原型会更好。我无法想象你为什么要改变宽度、高度、x和y…(alpha是一个简单的方法)
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

    let cell = tableView.dequeueReusableCellWithIdentifier("NewsCell", forIndexPath: indexPath) as! UITableViewCell

    cell.imageView?.image = nil
    let imgURL = NSURL(string: urlString)

    cell.imageView?.image = UIImage(named: "first")

    // cell.imageView?.image?.drawInRect(CGRectMake(0,0,50,50))
    // or
    // cell.imageView?.frame = CGRectMake(0,0,50,50)

    // also tried this


    cell.imageView?.image = UIImage(named: "first")  
    cell.imageView?.contentMode = .ScaleAspectFill
    cell.imageView?.clipsToBounds = true