在 Swift 中将 UIView 保存和检索为 NSData [英] Save and Retrieve UIView as NSData in Swift
本文介绍了在 Swift 中将 UIView 保存和检索为 NSData的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我打算在一个视图中保存 uiview 并在另一个视图中调用它(将其另存为 PDF)
I am indeting to save a uiview in one view and call it in another view (to save it as PDF)
有谁知道如何在 Swift 中将 UIView 保存和检索为 NSData?
Anyone knows how can I save and retrieve UIView as NSData in Swift?
推荐答案
根据此帖子,你可以试试这个:
According to this post, you could try this :
let yourViewToData = NSKeyedArchiver.archivedDataWithRootObject(yourView)
if let yourViewFromData = NSKeyedUnarchiver.unarchiveObjectWithData(yourViewToData) as? UIView {
// Do what you want with your view
}
这篇关于在 Swift 中将 UIView 保存和检索为 NSData的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文