I'm trying to create table cell with dynamic size, specifically height. Cell contains 4 lines of text and image view. Image inside the image view usually have big resolution, so it should be scaled to fit into the image view. I used aspectFit mode for scaling inside image view.
If I hardcode cell height, image view receive extra space(highlighted with color)
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat
{
return 500
}
To remove extra padding i need to calculate image dimensions after scaling. How can i do that in Swift?
Also i tried UITableViewAutomaticDimension, but the cell size become huge(depends on image resolution) as cells dimensions were calculated based on full resolution image, but not on scaled (with aspectFit mode)
Another solution was provided in this answer, but performance of this solution is very poor and unacceptable for table view. I believe there is better solution as image already scaled by system to fit the width, i just need to know the dimensions of scaled image.