【问题标题】:Darkening the MKMapView's background color without darkening the MKOverlay使 MKMapView 的背景颜色变暗而不使 MKOverlay 变暗
【发布时间】:2013-04-26 02:40:03
【问题描述】:

如何使MKMapView 的背景颜色变暗,而同时使MKMapView 中的MKOverlay 变暗——类似于Nike+ 应用程序。

【问题讨论】:

    标签: ios mkmapview uibackgroundcolor


    【解决方案1】:

    好的,我得到了解决方案,在添加其他叠加到地图之前,您可以添加一个总叠加作为地图的背景,这样地图的背景颜色就会改变,但是叠加仍然和以前一样,这是代码

    MKMapRect worldRect = MKMapRectWorld;
        MKMapPoint point1 = MKMapRectWorld.origin;
        MKMapPoint point2 = MKMapPointMake(point1.x+worldRect.size.width,point1.y);
        MKMapPoint point3 = MKMapPointMake(point2.x, point2.y+worldRect.size.height);
        MKMapPoint point4 = MKMapPointMake(point1.x, point3.y);
    
        MKMapPoint points[4] = {point1,point2,point3,point4};
        self.polygon = [MKPolygon polygonWithPoints:points count:4];
        [self.runMapView addOverlay:self.polygon];
    

    【讨论】:

    • 为什么不接受答案?在大量使用自定义叠加渲染器子类后,这只是救了我。
    【解决方案2】:

    斯威夫特 2.0

    let worldRect = MKMapRectWorld
    let point1 = MKMapRectWorld.origin
    let point2 = MKMapPointMake(point1.x + worldRect.size.width, point1.y)
    let point3 = MKMapPointMake(point2.x, point2.y + worldRect.size.height)
    let point4 = MKMapPointMake(point1.x, point3.y)
    var points = [point1, point2, point3, point4]
    let polygon = MKPolygon(points: &points, count: points.count)
    mapView.addOverlay(polygon)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-09
      • 2016-02-12
      • 2017-03-07
      • 2019-06-11
      • 2021-03-25
      相关资源
      最近更新 更多