苹果蓝与我的应用颜色不匹配,因此打印对话框非常刺耳。
在我的iPhone应用程序中,我可以使用以下UIPrintInteractionControllerDelegate代码获得正确的导航栏和背景颜色。
- (UIViewController *)printInteractionControllerParentViewController: (UIPrintInteractionController *)printInteractionController
{
return self.navigationController;
}
- (void)printInteractionControllerDidPresentPrinterOptions:(UIPrintInteractionController *)printInteractionController
{
self.navigationController.topViewController.view.backgroundColor = [UIColor whiteColor];
}
问题是我使用自定义UIPrintPageRenderer类来呈现我的页面。这似乎触发了在发送打印作业后弹出的屏幕。它有一个导航栏,上面有一个完成按钮,下面有一条消息说"发送到打印机"。我认为这是因为你可以看到多个页面被发送(我只有一个)。在选项对话框消失后弹出,并且您已经返回原始屏幕并启动了所有内容。
"发送到打印机"屏幕是蓝色的,丑陋到最大。无论如何要消除它或定制它的外观?"
答案 0 :(得分:2)
我不知道您的完整代码,但您可以尝试外观协议。这基本上允许您设置特定UI元素的通用颜色(或其他属性),如按钮和条形。因此,您可以设置打印控制器导航栏的背景颜色,使用以下代码:
[[UINavigationBar appearance] setTintColor:[UIColor redColor]];
这会使您应用中的所有导航栏(包括打印导航控制器)变为红色。然后你可以通过设置它们的条形图来改变那些你不想变成红色的东西(即self.navigationController.navigationBar.tintColor)。
顺便说一句,这适用于 iOS 7 ,iOS 6没有色彩属性,我认为它只是使用背景色。
答案 1 :(得分:0)
对于 iOS 13.0 + 你可以使用这个对我有用
if #available(iOS 13.0, *) {
let appearance = UINavigationBarAppearance()
appearance.configureWithOpaqueBackground()
appearance.backgroundColor = UIColor.orange
appearance.titleTextAttributes = [.foregroundColor: UIColor.white] // With a red background, make the title more readable.
UINavigationBar.appearance().standardAppearance = appearance
UINavigationBar.appearance().scrollEdgeAppearance = appearance
UINavigationBar.appearance().compactAppearance = appearance // For iPhone small navigation bar in landscape.
} else {
UINavigationBar.appearance().tintColor = UIColor.white
UINavigationBar.appearance().titleTextAttributes = [.foregroundColor: UIColor.white]
UINavigationBar.appearance().barTintColor = UIColor.orange
}
UIBarButtonItem.appearance().tintColor = UIColor.white
UISegmentedControl.appearance().tintColor = UIColor.orange