在 Swift 中将 UIView 保存并检索为 NSData

Save and Retrieve UIView as NSData in Swift

我打算在一个视图中保存 uiview 并在另一个视图中调用它(将其另存为 PDF)

有人知道如何在 Swift 中将 UIView 保存和检索为 NSData 吗?

根据这个post,你可以试试这个:

let yourViewToData = NSKeyedArchiver.archivedDataWithRootObject(yourView)
if let yourViewFromData = NSKeyedUnarchiver.unarchiveObjectWithData(yourViewToData) as? UIView {
  // Do what you want with your view
}