WWDC19 之后,Simulator 在 MapKit 包括的所有 Apple 框架下的 Meta,Core 层之上构建,Metal 利用底层 Mac 系统的 GPU
Google Map 需要开发人员密钥才能访问,这意味着从 GitHub 分叉存储库后,您无法直接在模拟器上运行它
可以通过嵌入在UIView.animate块中来调整地图交易
1 2 3 4 5 6 7 8
UIView.animate(withDuration: 1, delay: 0, options: .curveEaseInOut, animations: { [weakself] in self?.mapView.setCamera(MKMapCamera(lookingAtCenter: center, fromDistance: fromDistance, pitch: pitch, heading: 0), animated: true) }) { b in self.pinAnimation() UIView.animate(withDuration: 180, delay: 0, options: [.curveLinear, .autoreverse], animations: { [weakself] in self?.mapView.setCamera(MKMapCamera(lookingAtCenter: center, fromDistance: fromDistance, pitch: pitch, heading: heading), animated: true) }, completion: nil) }
Google Map 必须使用 CATransaction
1 2 3 4
CATransaction.begin() CATransaction.setValue(NSNumber(float: 1.0), forKey: kCATransactionAnimationDuration) // change the camera, set the zoom, whatever. CATransaction.commit()
if currentStep > totalSteps { timer.invalidate() return }
let start = currentStep-delta <0?0 : currentStep-delta let end = currentStep > route.count ? route.count : currentStep
let subCoordinates =Array(route[start..<end]) let currentSegment =MKPolyline(coordinates: subCoordinates, count: subCoordinates.count) self.mapView.addOverlay(currentSegment)