Search code examples
iosobjective-cgoogle-maps-sdk-iosgmsplacepicker

Changing search text color in GMSPlacePicker


I am using GMSPlacePicker in my app. It has a pretty simple API:

CLLocationCoordinate2D center = currentLocation.coordinate;
CLLocationCoordinate2D northEast = CLLocationCoordinate2DMake(center.latitude + 0.02, center.longitude + 0.02);
CLLocationCoordinate2D southWest = CLLocationCoordinate2DMake(center.latitude - 0.02, center.longitude - 0.02);
GMSCoordinateBounds *viewport = [[GMSCoordinateBounds alloc] initWithCoordinate:northEast
                                                                             coordinate:southWest];
GMSPlacePickerConfig *config = [[GMSPlacePickerConfig alloc] initWithViewport:viewport];
_placePicker = [[GMSPlacePicker alloc] initWithConfig:config];

[_placePicker pickPlaceWithCallback:^(GMSPlace *place, NSError *error) {

}];

It automatically presents itself from the ViewController on display at the moment. There is also a search feature which allows the user to search the place using text.

However, my app theme is black in color and I have set the navigation bar color using the UIAppearance proxy:

[[UINavigationBar appearance] setBarTintColor:[UIColor blackColor]];
[[UINavigationBar appearance] setTranslucent:NO];

Which causes a problem in search as the search text cannot be seen as the navigation bar background is black in color.

enter image description here

I have also tried using the UIAppearance proxy as suggested here to no effect.

[[UITextField appearanceWhenContainedIn:[UISearchBar class], nil] setTextColor:[UIColor whiteColor]];

Solution

  • This helped me:

    [[UISearchBar appearance] setBarStyle:UIBarStyleBlack]