【问题标题】:Firebase AuthUI iOS customisationFirebase AuthUI iOS 自定义
【发布时间】:2019-01-31 23:58:37
【问题描述】:

我正在尝试自定义 iOS 上默认 Firebase AuthUI 屏幕的配色方案。我可以更改 NavigationBar 文本颜色,但不能更改左侧 LeftNavigationBarItem 文本属性或主视图背景颜色。

这是我用来更改 NavigationBar 上主要文本属性的代码:

let authVC = authUI!.authViewController()
authVC.navigationBar.barTintColor = UIColor.black
authVC.navigationBar.barStyle = .blackTranslucent
authVC.navigationBar.titleTextAttributes = [NSAttributedStringKey.foregroundColor: UIColor (displayP3Red: 255/255, green: 212/255, blue: 121/255, alpha: 1.0)]

我尝试了以下代码,一次一行,来更改 NavigationBarItem 文本属性:

authVC.navigationBar.backItem?.backBarButtonItem?.setTitleTextAttributes([NSAttributedStringKey.foregroundColor: UIColor (displayP3Red: 255/255, green: 212/255, blue:121/255, alpha: 1.0) ], for: .normal)
authVC.navigationItem.backBarButtonItem?.setTitleTextAttributes([NSAttributedStringKey.foregroundColor: UIColor (displayP3Red: 255/255, green: 212/255, blue: 121/255, alpha: 1.0) ], for: .normal)

我已经尝试过更改视图背景属性,一次又是一行:

authVC.visibleViewController?.view.backgroundColor = UIColor.black 
authVC.view.backgroundColor = UIColor.black  
authVC.view.layer.backgroundColor = UIColor.black.cgColor
authVC.visibleViewController?.view.layer.backgroundColor = UIColor.black.cgColor

我正在使用 FirebaseUI (5.2.0)、FirebaseAuth (5.0.3) 和 Xcode 9.4.1。

任何指针将不胜感激。

谢谢

【问题讨论】:

    标签: firebase firebase-authentication firebaseui


    【解决方案1】:

    下面的代码是您将如何更改背景颜色,如 scoobydoo 指出的那样,在我添加自定义控制器作为根之后,我也能够修改我的 authViewController

    让 authViewController = MyAuthPickerViewController(authUI: authUI)

    nav = UINavigationController(rootViewController: authViewController)

    import UIKit
    import FirebaseUI
    
    class MyAuthPickerViewController : FUIAuthPickerViewController {
    
        override func viewDidLoad() {
            super.viewDidLoad()
    
            let scrollView = view.subviews[0]
            scrollView.backgroundColor = .clear
            let contentView = scrollView.subviews[0]
            contentView.backgroundColor = .clear
    
            let width = UIScreen.main.bounds.size.width
            let height = UIScreen.main.bounds.size.height
    
            let backgroundImage = UIImageView(frame: CGRect(x: 0, y: -1, width: width, height: height))
    
            backgroundImage.image = UIImage(named: "switchStarback")
            backgroundImage.alpha = 0.6
            view.backgroundColor = UIColor.init(named: "MatteBlack")
    
            backgroundImage.contentMode = UIView.ContentMode.scaleAspectFill
    
            view.insertSubview(backgroundImage, at: 0)
        }
    
    }
    

    【讨论】:

      【解决方案2】:

      这已通过继承 FUIAuthPickerViewController 并在 viewDidLoad 方法中设置 view.backgroundColor 进行排序

      【讨论】:

      • 你手边有子类代码吗?试图让它发挥作用。
      猜你喜欢
      • 2020-07-24
      • 1970-01-01
      • 1970-01-01
      • 2020-10-02
      • 2021-12-31
      • 1970-01-01
      • 2018-08-06
      • 1970-01-01
      • 2023-03-12
      相关资源
      最近更新 更多