我正在尝试使用以下代码更改导航栏标题的颜色,但不会更改。色彩和背景色完美搭配。
let nav = navigationController?.navigationBar
nav?.titleTextAttributes = [NSAttributedStringKey.foregroundColor: UIColor.white]
nav?.tintColor = UIColor.white
nav?.backgroundColor = UIColor.green.primary
title = "Share"
我没有更改应用程序委托中的任何内容。
Info.plist
<key>NSExtension</key>
<dict>
<key>NSExtensionAttributes</key>
<dict>
<key>NSExtensionActivationRule</key>
<dict>
<key>NSExtensionActivationSupportsText</key>
<string>1</string>
</dict>
<key>NSExtensionJavaScriptPreprocessingFile</key>
<string>Action</string>
</dict>
<key>NSExtensionMainStoryboard</key>
<string>MainInterface</string>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.share-services</string>
</dict>
答案 0 :(得分:0)
尝试更改导航的外观
UINavigationBar.appearance().tintColor = .black
我最近做了一个共享扩展程序,但只是更改了NavigationBar的颜色也不起作用。
答案 1 :(得分:0)
尝试以下解决方案:
self.navigationController?.navigationBar.barTintColor = UIColor.black
self.navigationController?.navigationBar.tintColor = UIColor.black
let titleDict = [NSAttributedStringKey.foregroundColor: UIColor.black, NSAttributedStringKey.font:constantsNaming.fontType.kOpenSans_SemiBoldLarge!]
self.navigationController?.navigationBar.titleTextAttributes = titleDict