获得UIView的快照有两种选择:
选项1:
UIGraphicsBeginImageContextWithOptions(sampleView.bounds.size, false, UIScreen.mainScreen().scale)
sampleView.drawViewHierarchyInRect(sampleView.bounds, afterScreenUpdates: true)
let image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
选项2:
UIGraphicsBeginImageContextWithOptions(sampleView.bounds.size, false, UIScreen.mainScreen().scale)
sampleView.layer.drawInContext(UIGraphicsGetCurrentContext())
let image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
有什么区别?
答案 0 :(得分:0)
目前,我发现option1必须使用主队列,这是一个串行队列。但是,option2可以在后台队列
的后台完成它的工作