彩色打印预览未显示UILabels

时间:2017-06-25 00:58:15

标签: ios swift ipad uiprintinteractioncntrler

在iPad打印预览中没有显示UILabels。当我放大打印预览时,它正确显示。当我将UILabel opaque属性更改为true时,它会将UILabel的背景更改为黑色并显示在打印预览上。这是我用来显示打印预览的代码。

let printController = UIPrintInteractionController.shared
let printInfo = UIPrintInfo(dictionary:nil)
printInfo.outputType = UIPrintInfoOutputType.general
printInfo.jobName = "Print"
printInfo.duplex = UIPrintInfoDuplex.none
printInfo.orientation = UIPrintInfoOrientation.portrait

printController.printPageRenderer = nil
printController.printingItems = nil
printController.printingItem = printUrl

printController.printInfo = printInfo
printController.showsNumberOfCopies = true
printController.showsPaperSelectionForLoadedPapers = true

printController.present(animated: true, completionHandler: nil)

当我将UIPrintInfoOutputType.general更改为UIPrintInfoOutputType.grayscale时,它会显示UILabels,但我需要彩色打印。灰度仅适用于黑色和黑色白色印刷。

1 个答案:

答案 0 :(得分:0)

我尝试了很多方法来解决我的问题,最后我找到了解决方案。

我将UILabel的opaque属性更改为true,然后将UILabel的背景颜色更改为白色。问题是,UILabel的背景颜色是默认。因此,在打印预览中,UILabel的背景显示为黑色。如果UILabel的背景颜色为默认清除颜色,则在打印预览中将显示为黑色。

printLabel.isOpaque = true
printLabel.backgroundColor = UIColor.white //Not Default or Clear Color
相关问题