提问者:小点点

Firebase AuthUI iOS 定制


我正在尝试自定义 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)

任何指示都将受到赞赏。

谢谢


共2个答案

匿名用户

下面的代码是你如何改变背景颜色,就像史酷比指出的那样,我也可以在添加自定义控制器作为根后修改我的authViewController,就像这样

让AuthViewController=MyAuthPickerViewController(AuthUI: AuthUI)

nav=UINavigationController(rootViewController: autViewController)

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)
    }

}

匿名用户

这已经通过子类化FUIAuthPickerViewController和在viewDidLoad方法中设置view.backgroundColor进行了排序