GMSAutocompleteViewController 中无法显示取消按钮

Cancel button can't shown in GMSAutocompleteViewController

我从

添加了自动完成 UI 控件 "Add a full-screen control"

https://developers.google.com/places/ios-api/autocomplete

并使用下面的代码在按下按钮时显示自动完成视图控制器。

let autocompleteController = GMSAutocompleteViewController()
autocompleteController.delegate = self
present(autocompleteController, animated: true, completion: nil)

下面的图片显示了我所得到的。 一切正常,但只有当我点击那里时才会显示取消按钮。

如果您使用以下类型代码,那么您将面临这个问题

UIBarButtonItem.appearance().setTitleTextAttributes([
        NSAttributedStringKey.foregroundColor: UIColor.white,
        NSAttributedStringKey.font: UIFont.systemFont(ofSize: 0.1)
    ], for: UIControlState.normal)

解决方案 - 将 UIControlState 更改为 UIControlState.normal

UIBarButtonItem.appearance().setTitleTextAttributes([
        NSAttributedStringKey.foregroundColor : UIColor.white,
        NSAttributedStringKey.font: UIFont.systemFont(ofSize: 0.1)
    ], for: UIControlState.application)