ios - 彩色打印预览不显示 UILabels

标签 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 时,它将显示 UILabel,但我需要彩色打印。灰度仅适用于黑白打印。

最佳答案

我尝试了很多方法来解决我的问题,终于找到了解决办法。

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

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

关于ios - 彩色打印预览不显示 UILabels,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44742250/

相关文章:

iphone - 等待 NSThread

ios - 如何在渲染动画后立即导航页面?

ios - NSFileProviderItem 下载角标(Badge)始终可见

ios - 如何在标题中制作搜索栏?

iOS - 替换后退按钮太靠近边缘

swift - 尝试编辑 Realm 中的列表

iphone - Ipad/iphone..操作表

iphone - UIDatePicker 在 iPad 上显示很奇怪,但在 iPhone 上显示正常

iphone - 核心数据的单例线程安全吗?

Swift - 在 map 中存储值。结构与类中的不同行为