tableView imageView内容模式不起作用?

时间:2016-01-27 08:38:10

标签: ios swift uitableview uiimage imageview

我有一张图片,在桌子行内,我试图通过高度/ 2来使它成为圆形

cell.imageView.frame.height/2

所以问题在于,当我试图将图像插入单元格时,图像不会改变其大小,我的代码看起来像这样

let named = "avatar.png"
let imageName = UIImage(named: named)
cell.imageView?.image = imageName
cell.backgroundColor = UIColor.clearColor()
if(tableArray[indexPath.row] == "avatar"){
    cell.imageView!.frame = CGRectMake(0,0,10,10)
    cell.imageView?.layer.borderWidth = 1
    cell.imageView?.layer.masksToBounds = true
    cell.imageView?.layer.borderColor = UIColor.blackColor().CGColor
    cell.imageView?.layer.cornerRadius = cell.imageView!.frame.height/2
    cell.imageView?.clipsToBounds = true
    cell.imageView?.contentMode = .ScaleAspectFit
}

我已经尝试了很多谷歌提出的建议,但是无法解决问题,有人可以提供帮助吗?

1 个答案:

答案 0 :(得分:1)

您无法更改默认UITableViewCell中存在的imageview的大小,如果您想更改imageview大小,则需要使用自定义UITableViewCell。