I have simple UITableView with some data. The table\'s height is greater than the screen size. Now I need to catch screenshot of this table (a whole table). I k
Swift 4 version of Parth Bhadaja's answer:
func generateImage(tableView:UITableView) -> UIImage {
UIGraphicsBeginImageContext(tableView.contentSize);
tableView.scrollToRow(at: NSIndexPath(row: 0, section: 0) as IndexPath, at: UITableViewScrollPosition.top, animated: false)
tableView.layer.render(in: UIGraphicsGetCurrentContext()!)
let row = tableView.numberOfRows(inSection: 0)
let numberofRowthatShowinscreen = 4
let scrollCount = row / numberofRowthatShowinscreen
for i in 0..
Should be noted that this function does return an image of the whole tableView, even cells which haven't been loaded onto the screen yet.