暗模式下的AirPrint问题

时间:2019-09-29 20:05:45

标签: swift background-color airprint ios-darkmode

我在UIPrintInteractionController中的黑暗模式下有问题!

我创建一个特定的视图(包含一个滚动视图和一个表视图)。 这些视图的背景色被强制为.white

该视图正确显示在屏幕上。 但预览结果显示为黑色背景。

enter image description here

func printView(title : String, view : UIView) {

    let printInfo = UIPrintInfo(dictionary:nil)
    printInfo.outputType = UIPrintInfo.OutputType.general
    printInfo.jobName = title
    printInfo.orientation = UIPrintInfo.Orientation.landscape

    // Set up print controller
    let printController = UIPrintInteractionController.shared
    printController.printInfo = printInfo

    // Assign a UIImage version of my UIView as a printing item
    printController.printingItem = view.toImage()

    // Do it
    printController.present(from: self.view.frame, in: view, animated: true) { (_, isPrinted, error) in
        if error == nil
        {
            if isPrinted
            {
                print ("Printed Successfully")
                self.dismiss(animated: true, completion: nil)
            }   else
            {
                print ("Printing failed")
                self.dismiss(animated: true, completion: nil)
            }

        }
    }
}

override func viewWillAppear(_ animated: Bool) {

    super.viewWillAppear(animated)

    self.view.backgroundColor = .white
    self.scrollView.backgroundColor = .white
    self.tableView.backgroundColor = .white
//...
}

0 个答案:

没有答案