【问题标题】:How to make Google maps marker title blink in iOS?如何让 Google 地图标记标题在 iOS 中闪烁?
【发布时间】:2018-07-03 06:55:56
【问题描述】:

我现在正在 iOS 上使用 google maps api,但我遇到了这个问题。我有一个带有特定标题的 GMSMarker。

markerTracker = GMSMarker(position: coordinate)
let markerImage = UIImage(named: "markerImage")!.withRenderingMode(.alwaysTemplate)
markerTracker!.title = Constants.alert
/* Do some other GMSMarker setup here */

有一种简单的方法可以让标记本身闪烁:

UIView.animate(withDuration: 1.0, delay: 0.0, options: [.repeat, .autoreverse], animations: {
                        self.markerTracker?.iconView!.alpha = 0.0
                    }, completion: nil)

结果将是闪烁的标记图像和标题窗口保持静止。

但是,我想反之亦然,保持标记图像不可变并使标题窗口闪烁。

任何想法如何实现这一目标?看来,当前的 API 只允许访问单个视图,即 iconView。我没有看到获得标题视图的方法。

【问题讨论】:

    标签: ios swift google-maps uiviewanimation


    【解决方案1】:

    您可以在此处找到自定义图像在地图上闪烁的来源。

    func animateFlash() {
            markerTracker.alpha = 0
            markerTracker.isHidden = false
            UIView.animate(withDuration: 0.3, animations: { markerTracker.alpha = 1.0 }) { finished in self.markerTracker.isHidden = true
                self.animateFlash()
            }
        }
    

    【讨论】:

    • 没有冒犯,但您是否正确阅读了我的问题?你的代码和我的代码一样。
    猜你喜欢
    • 2017-01-24
    • 1970-01-01
    • 2013-03-27
    • 2020-05-21
    • 2022-08-03
    • 1970-01-01
    • 1970-01-01
    • 2014-10-21
    • 1970-01-01
    相关资源
    最近更新 更多