- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我使用以下函数在 MKMapView 的 UIImage 快照上绘制折线。该功能有效,但对我来说太慢了。有什么办法可以加快速度吗?
func drawLineOnImageFromLocations(image: UIImage, snapshot: MKMapSnapshot,
polylineLocations: [CLLocation], color: CGColor) -> UIImage {
UIGraphicsBeginImageContextWithOptions(image.size, true, 0)
// draw original image into the context
image.draw(at: CGPoint.zero)
// get the context for CoreGraphics
guard let context = UIGraphicsGetCurrentContext() else {
return image
}
context.beginPath()
context.setLineWidth(10)
context.setStrokeColor(color)
let coordinates = polylineLocations.map{$0.coordinate}
var points = [CGPoint]()
for coordinate in coordinates {
let point = snapshot.point(for: coordinate)
points.append(point)
}
context.addLines(between: points)
context.strokePath()
// get the image from the graphics context
let resultImage = UIGraphicsGetImageFromCurrentImageContext()
// end the graphics context
UIGraphicsEndImageContext()
return resultImage!
}
最佳答案
结果调用:
UIGraphicsBeginImageContextWithOptions(image.size, true, 0)
是一个非常昂贵的操作。如果您可以重构您的代码以仅调用它一次,它将大大加快速度。
关于ios - 如何更快地在 MKMapSnapshotter 上绘图?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48842337/
我正在使用 MKMapSnapshotter 创建 MKMapView 的快照。这非常有效: let centerCoordinate = CLLocationCoordinate2DMake(-33
我有一个应用程序应该在后台获取对象并使用它们的位置数据为它们生成 map 快照。我自然而然地尝试了 MKMapSnapshotter。 事实证明(在对黑色 map 快照感到困惑数周之后)这个工具似乎只
我的 awakeWithContext 中有一个正在运行的 MKMapSnapshotter,我想为我的 imageView 设置它的图像。 问题是,MKMapSnapshotter 速度太慢,无法设
我正在使用 MKMapSnapshotter 创建 map 的屏幕截图,然后将其显示在 UIImageView 中。 let imageView = UIImageView() imageView.f
在连接到 Apple Watch 的真实 iPhone 上测试我的“ watch 应用程序”/iOS 应用程序 watch 扩展时,我遇到了 MKSnapshotter 的一些重大问题! 在我的一个接
我创建图钉图像的代码如下: MKMapSnapshotOptions *options = [[MKMapSnapshotOptions alloc] init]; options.region =
我使用以下函数在 MKMapView 的 UIImage 快照上绘制折线。该功能有效,但对我来说太慢了。有什么办法可以加快速度吗? func drawLineOnImageFromLocations(
是否有任何原因导致 MKMapSnapshotter 的 startWithCompletionHandler 方法上的完成处理程序不会被回调? (甚至没有错误!!) 我没有做任何花哨的事情,只是抓取
我正在使用 MKMapSnapshotter 创建一个小型 MKMapView 的 UIImage 屏幕截图(并存储以备后用)。但我注意到的一件事是它从快照中删除了“合法”标签。 Here答案是删除“
我们有一个 iOS 应用程序,它有一个 UITableView,其中包含在单元格出现时生成的 map 快照。我们使用的示例列表只是显示基于模型类中提供的纬度/经度的 map 快照。我开始注意到内存崩溃
我对 MKMapSnapshotter 有疑问。我目前有两个 View ,一个带有 UIButton,显示 UIActivityViewController,另一个带有 MKMapView,显示当前用
自 iOS 13 起,此代码返回黑色图像。任何想法? 我还记录了这些警告: InfoLog FlyoverNightShader: WARNING: 0:29: Overflow in implici
我正在尝试在 MKMapSnapshotter 中绘制一个 MKCircleRenderer。 所以我需要的是: 所以我有: 我的代码: + (void)renderMapRegion:(MKCoor
我正在尝试使用新的 iOS7 MKMapSnapshotter 生成静态 map 图像。每当我的应用程序需要 map 时,我都会调用以下命令: MKMapSnapshotter *snapshotte
我认为 iOS 7 的 MKMapSnapshotter 将是拍摄 MKMapView 快照的简单方法,好处是您可以在不将 map 加载到 View 中的情况下执行此操作.尽管添加图钉和叠加层似乎需要
我正在自己学习 Swift 3,我当前的学习项目涉及允许用户拍摄照片并获取固定当前位置的 map 快照。 我依赖 this answer从 2015 年 8 月和 this answer从 2016
我有一个 UITableView,它可能包含大量单元格,在某些单元格中,我想要一个 UIImageView 来显示一个位置的 map ,其中的坐标仅在运行时已知。 我希望表格 View 能够平滑滚动,
我想在 UITableViewCells 中显示 mapView, 所以我实际上写了这段代码 class DataPointTableCell: UITableViewCell { @IBOu
我有一个奇怪的问题:我像往常一样使用 openParentApplication:reply: 调用父应用程序。 使用异步 NSURLRequests 从 Internet 获取一些数据的工作做得很好
我正在开发适用于 MKMapSnapshotter API 的应用。 它制作具有所需区域的 map 快照。 它的代码从前台应用程序状态和主线程调用,如下所示: MKMapSnapshotOptions
我是一名优秀的程序员,十分优秀!