UIScrollViewのコンテンツ全体のスクリーンショットを撮る

UIViewのメソッド1発だけでは無理みたい。中身が全て見えるようにサイズ変更してから撮影する原始的な方法になります。データが非同期処理の場合は工夫が必要かも。

extension UIImage {
    
    convenience init(view: UIView) {
        let renderer = UIGraphicsImageRenderer(bounds: view.bounds)
        let image = renderer.image { context in
            view.layer.render(in: context.cgContext)
        }
        
        guard let cgImage = image.cgImage else {
            self.init()
            return
        }
        
        self.init(cgImage: cgImage)
    }
    
    convenience init(scrollView: UIScrollView) {
        let savedFrame = scrollView.frame
        let savedContentOffset = scrollView.contentOffset
        let savedHorizontalScroll = scrollView.showsHorizontalScrollIndicator
        let savedVerticalScroll = scrollView.showsVerticalScrollIndicator
        
        defer {
            scrollView.frame = savedFrame
            scrollView.contentOffset = savedContentOffset
            scrollView.showsHorizontalScrollIndicator = savedHorizontalScroll
            scrollView.showsVerticalScrollIndicator = savedVerticalScroll
        }
        
        scrollView.showsHorizontalScrollIndicator = false
        scrollView.showsVerticalScrollIndicator = false
        scrollView.contentOffset = .zero
        scrollView.frame = CGRect(origin: .zero, size: scrollView.contentSize)
        
        self.init(view: scrollView)
    }
}