【Swift】图片裁剪
程序员文章站
2022-04-09 08:05:12
...
/// 截图
///
/// - Parameters:
/// - view: view
/// - atFrame: rect
func imageFromView(view : UIView,atFrame:CGRect) -> UIImage {
UIGraphicsBeginImageContext(view.frame.size)
let context = UIGraphicsGetCurrentContext()
context?.saveGState()
UIRectClip(atFrame)
view.layer.render(in: context!)
let theImage = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return theImage!
}
上一篇: io流
下一篇: php裁剪图片文件(php截取图片文件)