swift - 屏幕截屏
作者:
GA_ | 来源:发表于
2017-03-14 16:08 被阅读224次 var snapshot: UIImage {
UIGraphicsBeginImageContext(view.bounds.size)
view.layer.renderInContext(UIGraphicsGetCurrentContext())
let image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return image
}
---swift 3.0---
extension UIView {
var snapshot: UIImage {
UIGraphicsBeginImageContext(self.bounds.size)
self.layer.render(in: UIGraphicsGetCurrentContext()!)
let image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return image!
}
}
本文标题:swift - 屏幕截屏
本文链接:https://www.haomeiwen.com/subject/ocdhnttx.html
网友评论