繁体   English   中英

“ drawViewHierarchyInRect”和“ drawInContext”之间有什么区别?

[英]What's the difference between “drawViewHierarchyInRect” and “drawInContext”?

拥有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()

有什么区别?

目前,我发现option1必须使用主队列,这是一个串行队列。 但是,option2可以在并发队列的后台执行其工作

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM