Google 地点 API Swift

Google Places API Swift

我正在尝试自定义 table 单元格分隔符颜色,但它没有生效,这是为什么?

autocompleteController.tableCellSeparatorColor = UIColor(red: CGFloat(255/255.0), green: CGFloat(255/255.0), blue: CGFloat(255/255.0), alpha: 1.0)

供参考:Google's Documentation

非常感谢任何帮助

class selectAddress: UIViewController {

    // Present the Autocomplete view controller when the button is pressed.
    //@IBAction func autocompleteClicked(_ sender: UIButton) {

    override func viewDidAppear(_ animated: Bool) {



        let autocompleteController = GMSAutocompleteViewController()
        autocompleteController.delegate = self

        autocompleteController.tableCellBackgroundColor = UIColor(red: CGFloat(35/255.0), green: CGFloat(35/255.0), blue: CGFloat(43/255.0), alpha: 1.0)

        autocompleteController.primaryTextColor = UIColor.gray
        autocompleteController.tableCellSeparatorColor = UIColor(red: CGFloat(255/255.0), green: CGFloat(255/255.0), blue: CGFloat(255/255.0), alpha: 1.0)
        autocompleteController.primaryTextHighlightColor = UIColor.white
        autocompleteController.secondaryTextColor = UIColor.white



    if opened == "NO" {
        self.present(autocompleteController, animated: true, completion: nil)
        opened = "YES"
    }else{
        opened = "NO"
         performSegue(withIdentifier: "venueSave", sender: self)


        }
   // }
}
}

extension selectAddress: GMSAutocompleteViewControllerDelegate {



    // Handle the user's selection.
    func viewController(_ viewController: GMSAutocompleteViewController, didAutocompleteWith place: GMSPlace) {
        print("Place name: \(place)")
        print("Place address: \(place.formattedAddress)")
        print("Place attributions: \(place.attributions)")
        print("Longitude: \(place.coordinate.longitude)")
        print("Latitude: \(place.coordinate.latitude)")
        print("Address components: \(place.addressComponents)")


        let city = place.addressComponents?[2].name

        print("CITYYYY \(city!)")

        /*
        var request = URLRequest(url: URL(string: "https://www.asmserver.co.uk/barduo/addvenue.php")!)
        request.httpMethod = "POST"
        let postString = "name=\(facebookID!)&email=\(email!)&firstname=\(firstName!)&lastname=\(lastName!)&link=\(link!)"
        print(postString)
        request.httpBody = postString.data(using: .utf8)
        let task = URLSession.shared.dataTask(with: request) { data, response, error in
            guard let data = data, error == nil else {                                                 // check for fundamental networking error
                print("error=\(error)")
                return
            }

            if let httpStatus = response as? HTTPURLResponse, httpStatus.statusCode != 200 {           // check for http errors
                print("statusCode should be 200, but is \(httpStatus.statusCode)")
                print("response = \(response)")
            }

            let responseString = String(data: data, encoding: .utf8)

            print("*****\(responseString!)")

            defaults.set("\(responseString!)", forKey: "id")

            DispatchQueue.main.async {
                self.performSegue(withIdentifier: "goNext", sender: self)
            }

        }
        task.resume()

*/

        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
    }

    func viewController(viewController: GMSAutocompleteViewController!, didFailAutocompleteWithError error: NSError!) {
        // TODO: handle the error.
        print("Error: ", error.description)
    }

}

我将相关行更改为:

GMSAutocompleteViewController().tableCellSeparatorColor = UIColor.white

现在出现白色分隔符。