设置DarkTheme无效Braintree iOS v4 SDK

时间:2019-01-13 21:55:59

标签: swift braintree

文档清楚地表明可以做到,轻而易举: https://developers.braintreepayments.com/guides/drop-in/customization/ios/v4#themes

我确实可以将primaryTextColor自定义为红色。

这是一个屏幕截图,该屏幕演示了红色有效但不是darkTheme: enter image description here

这是我的UIViewController中的代码:

port

1 个答案:

答案 0 :(得分:1)

因此布伦特里(Braintree)的documentation on Theme's在IMO措辞上选择不当。

该说明对我有误解:“要改用Dark主题,请在初始化Drop-in之前调用此方法”。但是,您必须在设置darkTheme之前初始化或实例化插件。

该说明最好读为:“要改用Dark主题,请在展示Drop-in之前调用此方法”

这是我的工作代码:

override func viewDidAppear(_ animated: Bool) {
    super.viewDidAppear(animated)
    showDropIn(clientTokenOrTokenizationKey: clientToken)
}

func showDropIn(clientTokenOrTokenizationKey: String) {
    let request =  BTDropInRequest()
    request.vaultManager = true

    dropIn = BTDropInController(authorization: clientTokenOrTokenizationKey, request: request)
    { (controller, result, error) in
        if (error != nil) {
            print("ERROR")
        } else if (result?.isCancelled == true) {
            print("CANCELLED")
        } else if let result = result {
            // Use the BTDropInResult properties to update your UI
            // result.paymentOptionType
            // result.paymentMethod
            // result.paymentIcon
            // result.paymentDescription
        }
        controller.dismiss(animated: true, completion: nil)
    }

    BTUIKAppearance.darkTheme()
    BTUIKAppearance.sharedInstance()?.primaryTextColor = UIColor.lightGray
    self.present(dropIn!, animated: true, completion: nil)
}