ios – 彩色打印预览未显示UILabels

前端之家收集整理的这篇文章主要介绍了ios – 彩色打印预览未显示UILabels前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
在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,但我需要彩色打印.灰度仅适用于黑色和黑色白色印刷.

解决方法

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

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

printLabel.isOpaque = true
printLabel.backgroundColor = UIColor.white //Not Default or Clear Color

猜你在找的iOS相关文章