我通过修改此处的代码找到了我的问题的答案:
AirPrint contents of a UIView
//create an extension to covert the view to an image extension UIView { func toImage() -> UIImage { UIGraphicsBeginImageContextWithOptions(bounds.size,false,UIScreen.mainScreen().scale) drawViewHierarchyInRect(self.bounds,afterScreenUpdates: true) let image = UIGraphicsGetimageFromCurrentimageContext() UIGraphicsEndImageContext() return image } } //In your view controller @IBAction func printButton(sender: AnyObject) { let printInfo = uiprintinfo(dictionary:nil) printInfo.outputType = uiprintinfoOutputType.General printInfo.jobName = "My Print Job" // Set up print controller let printController = UIPrintInteractionController.sharedPrintController() printController.printInfo = printInfo // Assign a UIImage version of my UIView as a printing iten printController.printingItem = self.view.toImage() // Do it printController.presentFromrect(self.view.frame,inView: self.view,animated: true,completionHandler: nil) }