swift - 如何在 Swift 4 中将 navigationItem.title 更改为白色?

标签 swift firebase uinavigationitem

如何在 Swift 4 中将 navigationItem.title 更改为白色?

let uid = Auth.auth().currentUser?.uid
Database.database().reference().child("users").child(uid!).observeSingleEvent(of: .value, with: {(snapshot) in          
    if let dictionary = snapshot.value as? [String: AnyObject] {
        self.navigationItem.title = dictionary["name"] as? String
        self.navigationController?.navigationBar.prefersLargeTitles = true
    }
},withCancel: nil)

最佳答案

您可以使用此更改标题颜色:

self.navigationController?.navigationBar.titleTextAttributes = [NSAttributedStringKey.foregroundColor: UIColor.white]

关于swift - 如何在 Swift 4 中将 navigationItem.title 更改为白色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50554081/

相关文章:

python - Swift 序列化使用 Python 生成的稀疏矩阵

firebase - Firestore 无法使用 Flutter for iOS 构建

ios6 - segue 样式 "Replace"后缺少导航栏按钮项

uinavigationcontroller - 当搜索栏显示在前一个 View 的导航栏中时,无法在插入的 vc 导航栏中更改后退按钮标题 "Search"

ios - Swift - 按下 BarButtonItem 时以编程方式创建和显示 UIPickerView

ios - Admob pod 在 firebase 集成后不起作用

swift - 我如何同步 AVCaptureDevice setFocusModeLockedWithLensPosition 调用

firebase - Flutter firebase - 无法捕获异常抛出的白色尝试使用带有空键的 map 更新文档

firebase - 部署时使 Google Cloud Function 的 Firebase 缓存无效

ios - backBarButtonItem 显示图像不正确