Created
June 12, 2018 04:24
-
-
Save farhan-syed/cb6f3171e1ecc658b4c7f1505f841c0c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension UIImage { | |
func calcImageRatio() -> CGFloat { | |
let imageRatio = CGFloat(self.size.width / self.size.height) | |
return imageRatio | |
} | |
} | |
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { | |
let currentImage = images[indexPath.row] | |
let imageRatio = currentImage.calcImageRatio() | |
return tableView.frame.width / imageRatio | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment