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
For snapshot in of uitableview with swift 2.2:
func printScreen(){
UIGraphicsBeginImageContextWithOptions(Table_LigaParcial.contentSize, false, UIScreen.mainScreen().scale)
Table_LigaParcial.scrollToRowAtIndexPath(NSIndexPath(forRow: 0, inSection: 0), atScrollPosition: UITableViewScrollPosition.Top, animated: false)
Table_LigaParcial.layer.renderInContext(UIGraphicsGetCurrentContext()!)
let row = Table_LigaParcial.numberOfRowsInSection(0)
let numberofRowthatShowinscreen = 4
var scrollCount = row / numberofRowthatShowinscreen
for var i=0;i < scrollCount ; i+=1 {
Table_LigaParcial.scrollToRowAtIndexPath(NSIndexPath(forRow: (i)*numberofRowthatShowinscreen, inSection: 0), atScrollPosition: UITableViewScrollPosition.Top, animated: false)
Table_LigaParcial.layer.renderInContext(UIGraphicsGetCurrentContext()!)
}
let image:UIImage = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext();
}