【发布时间】:2019-02-13 22:31:01
【问题描述】:
我有这个 gif 图片:
我可以使用以下代码添加自定义静态图像作为标记:
if let location = locationManager.location {
currentLocationMarker = GMSMarker(position: location.coordinate)
currentLocationMarker?.icon = UIImage(named: "user")
currentLocationMarker?.map = mapView
currentLocationMarker?.rotation = locationManager.location?.course ?? 0
}
我想用这个 gif 图像作为标记。到底有没有?虽然我知道鼓励使用静态图像,但有可能吗?
我正在考虑添加一个UIView 说一个100x100 视图并在其中设置此图标的动画,尚未尝试但我尝试了此线程中提到的解决方案:How to load GIF image in Swift? 为:
let jeremyGif = UIImage.gifImageWithName("puppy")
let imageView = UIImageView(image: jeremyGif)
imageView.frame = CGRect(x: 0, y: 0, width: jeremyGif?.size.width ?? 100.0, height: jeremyGif?.size.height ?? 100.0)
//view.addSubview(imageView)
//mapView.addSubview(imageView)
if let location = locationManager.location {
currentLocationMarker = GMSMarker(position: location.coordinate)
currentLocationMarker?.icon = imageView.image //UIImage(named: "user")
currentLocationMarker?.map = mapView
currentLocationMarker?.rotation = locationManager.location?.course ?? 0
}
但这样做也不起作用。我在资产中添加了这个 gif 图像,它是这样显示的:
【问题讨论】:
标签: ios swift google-maps google-maps-markers cllocationmanager