hi all, i'm trying to capture a screen shot, so i wrote a UIView extension that renders itself to UIImage like that:
extension UIView {
func toImage() -> UIImage {
UIGraphicsBeginImageContextWithOptions(bounds.size, false, 0.0)
drawViewHierarchyInRect(bounds, afterScreenUpdates: false)
let img = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return img
}
}It seems worked on apple tv simulator but its not working on device.
What is the trick of the rendering a UIView to UIImage or capturing screen and returning as UIImage on tvOS different from iOS ?
Thanks.