用Google maps iOS sdk在swift中创建自定义信息窗口? [英] Creating custom info window in swift with the Google maps iOS sdk?

查看:272
本文介绍了用Google maps iOS sdk在swift中创建自定义信息窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个xib和一个视图控制器,并且想要在swift中为其显示一个标记的自定义信息窗口。在互联网上搜索后,我发现OBJ-C中有一个旧教程,但这不会帮助我。

I have created a xib and a view controller, and want to display it a customised info window for a marker in swift. After searching on the Internet I have found an old tutorial in OBJ-C however this will not help me.

谢谢。

markerInfoWindow方法 from GMSMapViewDelegate

Sample implementation to show an custom info window in Swift:

在Swift中显示自定义信息窗口的示例实现:

func mapView(mapView: GMSMapView!, markerInfoWindow marker: GMSMarker!) -> UIView! { var infoWindow = NSBundle.mainBundle().loadNibNamed("CustomInfoWindow", owner: self, options: nil).first! as CustomInfoWindow infoWindow.label.text = "\(marker.position.latitude) \(marker.position.longitude)" return infoWindow }

You can visit this GitHub page for detail implementation.

您可以访问此GitHub页面以获得详细的实现。

Depends on how you want your info window looks like, you can change the background color by doing infoWindow.backgroundColor = UIColor.redColor(), or change the shape of your info window by doing infoWindow.layer.cornerRadius = 10.0f, or even add an image by doing infoWindow.imageView.image = UIImage(named: "image.jpg").

这篇关于用Google maps iOS sdk在swift中创建自定义信息窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆