I am trying to change the navigation bars title color using the below code but it won't change. The tint and background color work perfectly.
let nav = navigationController?.navigationBar
nav?.titleTextAttributes = [NSAttributedStringKey.foregroundColor: UIColor.white]
nav?.tintColor = UIColor.white
nav?.backgroundColor = UIColor.green.primary
title = "Share"
I haven't changed anything in the App Delegate.
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>
Try change appearance of navigation
UINavigationBar.appearance().tintColor = .black
I made a share extension recently, but just change navigationBar's color doesn't work too.
Try this solution:
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.