代码如下:
UIGraphicsBeginImageContextWithOptions(poolView.k_size, false, UIScreen.main.scale)
poolView.layer.render(in: UIGraphicsGetCurrentContext()!)
Aview.drawHierarchy(in: poolView.bounds, afterScreenUpdates: false)
let viewImage = UIGraphicsGetImageFromCurrentImageContext()!
UIGraphicsEndImageContext()
其中的poolview为要截图的view,Aview为poolview的父视图,OC转换下写法即可
网友评论