A simple subclass of UITextField for getting auto complete place search from Google Places.
Just Drag and Drop AJAutoCompletePlaceTextField in your project.
- Install Google Places SDK using
CocoaPods
. - Refer GooglePlacesAPIConsole and get an API key.
To see it in action clone the repo install pods and run the sample project
- Just give your textfield class as
AJAutoCompletePlaceTextField
- Add GMSPlacesClient.provideAPIKey("API_KEY") in
application:didFinishLaunchingWithOptions
of AppDelegate file. - To know which place user has selected use
selectedPlace:
This returns the selected place with it's indexPath.
objAJAutoCompletePlaceTextField.selectedPlace = { place , indexPath in
//Get your selected place and indexPath here
}
- For getting highlighted typed text use
objAJAutoCompletePlaceTextField.highLightTypeTextedEnabled = true
- For setting maximum number of data count in table use
objAJAutoCompletePlaceTextField.maxAutoCompleteDataCount = 5
- For customizing Highlighted Type Text Attributes use
objAJAutoCompletePlaceTextField.highLightTypeTextedAttributes = [NSForegroundColorAttributeName:UIColor.black]
objAJAutoCompletePlaceTextField.highLightTypeTextedAttributes![NSFontAttributeName] = UIFont.boldSystemFont(ofSize: 12)
- For customizing Text Font and Size in Normal mode use
objAJAutoCompletePlaceTextField.autoCompleteTextFont = UIFont.systemFont(ofSize: 12)
objAJAutoCompletePlaceTextField.autoCompleteTextColor = UIColor.black
AJAutoCompletePlaceTextField
is available under the MIT license. See the LICENSE file for more info.
For any queries and suggestions reach out at [email protected]