2017-04-17 10 views
0

私は自分のアプリに "Place Autocomplete"を使用します。 私を助けてください。 は、私が変更したい:Googleプレイスのオートコンプリートでキャンセルボタンのテキストとフォントを変更するにはどうすればよいですか?

1 - ボタンテキストとフォント 2を取り消す - プライマリテキストフォントとセカンダリテキストフォントを 3 - エラーおよびメッセージのテキストフォント 4 - ボタンテキストとフォント「をもう一度試してみてください」 enter image description here

import UIKit 
import GooglePlaces 

class ViewController: UIViewController { 

    // Present the Autocomplete view controller when the button is pressed. 
    @IBAction func autocompleteClicked(_ sender: UIButton) { 
    let autocompleteController = GMSAutocompleteViewController() 
    autocompleteController.delegate = self 
    present(autocompleteController, animated: true, completion: nil) 
    } 
} 

extension ViewController: GMSAutocompleteViewControllerDelegate { 

    // Handle the user's selection. 
    func viewController(_ viewController: GMSAutocompleteViewController, didAutocompleteWith place: GMSPlace) { 
    print("Place name: \(place.name)") 
    print("Place address: \(place.formattedAddress)") 
    print("Place attributions: \(place.attributions)") 
    dismiss(animated: true, completion: nil) 
    } 

    func viewController(_ viewController: GMSAutocompleteViewController, didFailAutocompleteWithError error: Error) { 
    // TODO: handle the error. 
    print("Error: ", error.localizedDescription) 
    } 

    // User canceled the operation. 
    func wasCancelled(_ viewController: GMSAutocompleteViewController) { 
    dismiss(animated: true, completion: nil) 
    } 

    // Turn the network activity indicator on and off again. 
    func didRequestAutocompletePredictions(_ viewController: GMSAutocompleteViewController) { 
    UIApplication.shared.isNetworkActivityIndicatorVisible = true 
    } 

    func didUpdateAutocompletePredictions(_ viewController: GMSAutocompleteViewController) { 
    UIApplication.shared.isNetworkActivityIndicatorVisible = false 
    } 

} 

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

+0

をスウィズル客観Cを使用して、再びこれをチェックされhttps://developers.google.com/places/ios-api/reference/ interface_g_m_s_autocomplete_view_controller、https://developers.google.com/places/ios-api/autocomplete – karthikeyan

答えて

1

GMSAutocompleteViewController残念ながら、UI要素のフォントを変更することはできません。ダイアログでテーブルビューのフォントを変更するには

0

一つの方法は、

@implementation GMSAutocompleteTableDataSource(ae_custom_font) 

-(UITableViewCell *) ae_swizzle_tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    UITableViewCell* cell = [self ae_swizzle_tableView:tableView cellForRowAtIndexPath:indexPath]; 
    if([(UILabel*)cell.subviews[0].subviews[0] isKindOfClass:[UILabel class]]) 
    ((UILabel*)cell.subviews[0].subviews[0]).font = [UIFont systemFontOfSize:10]; 
    return cell; 
} 

@end 

@interface AutoCompleteVC: GMSAutocompleteViewController 
@end 

@implementation AutoCompleteVC 

-(void) viewDidLayoutSubviews 
{ 
    [super viewDidLayoutSubviews]; 
    static dispatch_once_t once_token; 
    dispatch_once(&once_token, ^{ 
     SEL cellForRowSelector = @selector(tableView:cellForRowAtIndexPath:); 
     SEL customCellForRowSelector = @selector(ae_swizzle_tableView:cellForRowAtIndexPath:); 
     Method originalMethod = class_getInstanceMethod([GMSAutocompleteTableDataSource class], cellForRowSelector); 
     Method extendedMethod = class_getInstanceMethod([GMSAutocompleteTableDataSource class], customCellForRowSelector); 
     method_exchangeImplementations(originalMethod, extendedMethod); 
    }); 
} 

@end 
関連する問題