问题描述:

I have an array of png icons homeIcons[] that load into the cells of my tableView. Unfortunately, they are too big and want them to shrink a bit. Trying to shrink them with this code:

 let cellIcon = UIImage(named: homeIcons[indexPath.row])

cell.imageView!.frame = CGRect(x: cell.imageView!.frame.origin.x, y: cell.imageView!.frame.origin.y, width: cell.imageView!.frame.size.width / 2, height: cell.imageView!.frame.size.height / 2)

cell.imageView!.image = cellIcon

Changing the frame width and height doesn't do anything. Is there anyway to change the size of my icons or am I forced to redraw my images?

网友答案:

Better if can add auto layout constraint to your imageview from storyboard. or try calling layoutIfNeeded() after setting new frame.

相关阅读:
Top