0
我有这样的方法:与谷歌continus动画映射
private func setupCameraPositionForMovement(markerPos: CLLocationCoordinate2D, secondPos: CLLocationCoordinate2D) {
let bearing = bearingBetweenLatLngs(markerPos, end: secondPos)
let cameraPosition = GMSCameraPosition(target: markerPos, zoom: 16, bearing: bearing + 20, viewingAngle: 90)
map.animateToCameraPosition(cameraPosition)
}
我使用这个方法来制作动画运动从markerPos
到secondPos
,而这项工作很好,当我一旦称呼它:
CATransaction.begin()
CATransaction.setAnimationDuration(1)
setupCameraPositionForMovement(markers[selectedIndex - 1].position, secondPos: markers[selectedIndex].position)
CATransaction.commit()
现在,我想多次调用这个动画来显示一个继续动作, 所以我试过这段代码:
for i in 1..<markers.count {
CATransaction.begin()
CATransaction.setAnimationDuration(1)
setupCameraPositionForMovement(markers[i - 1].position, secondPos: markers[i].position)
CATransaction.commit()
}
但没有任何好处。
当我搜索这个问题时,我发现像CAAnimationGroup
,但我不知道如何在这种情况下使用它。
任何人都可以帮助我吗?
那么,在我的情况下,我可以如何继续运动? – wajeeh