自定义InfoWindow标记谷歌地图SDK,Swift 2.0

我试图在Swift 2.0中实现这个( https://www.youtube.com/watch?v=ILiBXYscsyY)Custom InfoWindow教程。 我试图通过混合匹配Objective-C和Swift代码来做到这一点,但我一直在翻译不成功

- (UIView *) mapView:(GMSMapView *)mapView markerInfoWindow:(GMSMarker *)marker { CustomInfoWindow *infoWindow = [[[NSBundle MainBundle] loadNibNamed:@"InfoWindow" owner:self options:nil] objectAtIndex:0]; infoWindow.name.text = @"Syndey Opera House"; infoWindow.address.text = @"Bennelong Point, Sydney"; infoWindow.photo.image = [UIImage imageNamed:@"SydneyOperaHouseAtNight"]; return infoWindow; } 

进入Swift。 本教程的这一部分可以在video的3:07find。

我想在将本教程翻译成Swift 2.0方面有所帮助,或者如果有人知道Swift 2.0的一个很好的教程,将不胜感激。

这是上面的代码:

 func mapView(mapView: GMSMapView!, markerInfoWindow marker: GMSMarker!) -> UIView! { let infoWindow = NSBundle.mainBundle().loadNibNamed("InfoWindow", owner: self, options: nil).first as! CustomInfoWindow infoWindow.name.text = "Sydney Opera House" infoWindow.address.text = "Bennelong Point Sydney" infoWindow.photo.image = UIImage(named: "SydneyOperaHouseAtNight") return infoWindow } 

这里是Swift3的代码:

 func mapView(_ mapView: GMSMapView, markerInfoWindow marker: GMSMarker) -> UIView? { let infoWindow = Bundle.main.loadNibNamed("InfoWindow", owner: self, options: nil)?.first as! CustomInfoWindow infoWindow.name.text = "Sydney Opera House" infoWindow.address.text = "Bennelong Point Sydney" infoWindow.photo.image = UIImage(named: "SydneyOperaHouseAtNight") return infoWindow }