gpt4 book ai didi

ios - UIImagePickerController 中的左右 barButtons 字体

转载 作者:行者123 更新时间:2023-11-30 14:07:39 24 4
gpt4 key购买 nike

如何为UIImagePickerController的左右UIBarButton设置自定义字体?

我已经尝试过这段代码,但它不起作用:

let imagePicker = UIImagePickerController()
imagePicker.navigationBar.barTintColor = UIColor(hex: 0x212121)
imagePicker.navigationBar.translucent = false
imagePicker.navigationBar.tintColor = UIColor.whiteColor()
imagePicker.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName: UIColor.whiteColor(), NSFontAttributeName: UIFont(name: "Roboto-Regular", size: 20.0)!]

// doesn't work
imagePicker.navigationItem.backBarButtonItem?.setTitleTextAttributes([NSForegroundColorAttributeName: UIColor.whiteColor(), NSFontAttributeName: UIFont(name: "Roboto-Regular", size: 25.0)!], forState: UIControlState.Normal)
imagePicker.navigationItem.leftBarButtonItem?.setTitleTextAttributes([NSForegroundColorAttributeName: UIColor.whiteColor(), NSFontAttributeName: UIFont(name: "Roboto-Regular", size: 20.0)!], forState: UIControlState.Normal)
imagePicker.navigationItem.rightBarButtonItem?.setTitleTextAttributes([NSForegroundColorAttributeName: UIColor.whiteColor(), NSFontAttributeName: UIFont(name: "Roboto-Regular", size: 20.0)!], forState: UIControlState.Normal)

最佳答案

您将需要子类化 UIImagePickerController 并设置您自己的工具栏。

苹果有一个很好的例子:https://developer.apple.com/library/ios/samplecode/PhotoPicker/Introduction/Intro.html

它是用 Objective-C 编写的,但我相信它会让你了解你需要做什么。

关于ios - UIImagePickerController 中的左右 barButtons 字体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32166584/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com