Tec*_*ain 8 xcode uicolor ios swift gmsautocomplete
我在 ios 中使用 Google 自动完成 placekicker。它向我展示了具有本机设计的控制器。我想自定义它的导航栏颜色。但我无法做到。下面是代码
let autocompleteController = GMSAutocompleteViewController()
autocompleteController.tintColor = UIColor.red
autocompleteController.navigationController?.navigationBar.barTintColor = Constant.AppColor.navigationColor
autocompleteController.delegate = self
self.present(autocompleteController, animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud)
我写了这段代码来适应明/暗模式:
迅速
let controller:GMSAutocompleteViewController! = GMSAutocompleteViewController()
if #available(iOS 13.0, *) {
if UIScreen.mainScreen.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark {
controller.primaryTextColor = UIColor.whiteColor
controller.secondaryTextColor = UIColor.lightGrayColor
controller.tableCellSeparatorColor = UIColor.lightGrayColor
controller.tableCellBackgroundColor = UIColor.darkGrayColor
} else {
controller.primaryTextColor = UIColor.blackColor
controller.secondaryTextColor = UIColor.lightGrayColor
controller.tableCellSeparatorColor = UIColor.lightGrayColor
controller.tableCellBackgroundColor = UIColor.whiteColor
}
}
Run Code Online (Sandbox Code Playgroud)
目标-C
GMSAutocompleteViewController *controller = [[GMSAutocompleteViewController alloc] init];
if (@available(iOS 13.0, *)) {
if(UIScreen.mainScreen.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark ){
controller.primaryTextColor = UIColor.whiteColor;
controller.secondaryTextColor = UIColor.lightGrayColor;
controller.tableCellSeparatorColor = UIColor.lightGrayColor;
controller.tableCellBackgroundColor = UIColor.darkGrayColor;
} else {
controller.primaryTextColor = UIColor.blackColor;
controller.secondaryTextColor = UIColor.lightGrayColor;
controller.tableCellSeparatorColor = UIColor.lightGrayColor;
controller.tableCellBackgroundColor = UIColor.whiteColor;
}
}
Run Code Online (Sandbox Code Playgroud)
结果:
| 归档时间: |
|
| 查看次数: |
4055 次 |
| 最近记录: |