打印很简单 就这个一个方法即可:
直接上代码
class func printText(text: NSAttributedString) -> Void {
let print = UIPrintInteractionController.shared;
print.printInfo = UIPrintInfo.printInfo();
print.printInfo?.outputType = UIPrintInfoOutputType.general;
print.printInfo?.jobName = "笔记";
print.printInfo?.duplex = .longEdge;
print.printInfo?.orientation = .portrait;
let textFormater = UISimpleTextPrintFormatter(attributedText: text);
textFormater.startPage = 0;
textFormater.contentInsets = UIEdge(size: 36);
print.printFormatter = textFormater;
print.present(animated: true) { (ctrl, bs, error) in
};
}