문제

How would one darken the MKMapView's background color, and NOT darken the MKOverlay in the MKMapView's at the same time -- similar to the map view in the Nike+ app.

도움이 되었습니까?

해결책

OK , I got the solution here ,before add other overlays to the map ,you can add a total overlay as a background to the map ,so the map's background color is changed ,but the overlay is still as they are before ,here are codes

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];

다른 팁

Swift 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)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top