我正在尝试在 MGLAnnotation
上使用 CABasicAnimation
或关键帧动画,但自从 MGLAnnotation
不调用“addAnimation”。
根据旧文档,可以使用 RMMarker
,但新版本中不存在此类。
https://www.mapbox.com/mapbox-ios-sdk-legacy/examples/simple-cabasicanimation/
我像这样创建了 CABasicAnimation
对象:
let hover = CABasicAnimation(keyPath: "position")
hover.additive = true
hover.fromValue = NSValue(CGPoint: CGPointZero)
hover.toValue = NSValue(CGPoint: CGPointMake(0.0, -15.0))
hover.autoreverses = true
hover.duration = 1.0
hover.repeatCount = 500
hover.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseOut)
我无法将此动画添加到任何可能的类中。
有什么解决办法吗?
最佳答案
从 Mapbox iOS SDK v3.2.1 开始,动画注释并不容易。 MGLAnnotation 直接在 GL 级别呈现,不是 UIView 的子类,这意味着不能应用典型的 Core Animation 技术。
允许使用原生 View (例如,基于 UIView 的 View )作为注释是 v3.3.0 的计划功能。
关于ios - 无法将 CABasicAnimation 与 Mapbox iOS 框架一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36980253/