测试已测试 | ✗ |
语言语言 | SwiftSwift |
许可证 | MIT |
发布最后发布 | 2017年1月 |
SwiftSwift 版本 | 3.0 |
SPM支持 SPM | ✗ |
由 Ihor Rapalyuk 维护。
Swift iOS Pod。GooglePlacesPicker 允许用户选择 Google 地点。
导入
import GooglePlacesPicker
Cocoapods
pod 'GooglePlacesPicker'
1) 您需要像这样设置您的 API 密钥
GooglePlaces.googlePlacesAPIKey = "[KEY]"
2) 实现您需要的 GooglePlacePickerViewControllerDelegate 方法
func googlePlacePicker(googlePlacePickerViewController: GooglePlacePickerViewController, didSelectGooglePlace googlePlace: GooglePlace)
func googlePlacePickerViewControllerDidPressCancelButton(googlePlacePickerViewController: GooglePlacePickerViewController)
3) 显示 GooglePlacesPicker
let alert = GooglePlacePickerViewController()
alert.delegate = self
self.presentViewController(alert, animated: true, completion: nil)
要自定义选择器,简单地从 GooglePlacePickerViewController 继承并重写 updateUI 方法,如下所示
import GooglePlacesPicker
class TestGooglePlacePickerViewController: GooglePlacePickerViewController {
override func updateUI() {
super.updateUI()
self.leftBarButtonItem?.tintColor = UIColor.blackColor()
self.rightBarButtonItem?.tintColor = UIColor.blackColor()
self.navigationBar?.barTintColor = UIColor.redColor()
}
}
示例项目 https://github.com/letzgro/GooglePlacesPicker/tree/master/GooglePlacesPickerExample