我正在尝试实现这个( https://www.youtube.com/watch?v=ILiBXYscsyY)自定义InfoWindow教程,该教程是在Swift 2.0中为Objective-C完成的.我试过通过混合匹配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; }
进入斯威夫特.本教程的这一部分可以在视频的3:07找到.
我想在将本教程翻译成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 }