I am working on an app for iOS 7, and am trying to change the map from day to night and night to day mode. I have not found any relevant APIs in iOS 7 documentation to do this.
This is not a built in feature of MKMapKit
so what you are asking is not possible without doing it yourself. If you were going to do it yourself, the best you could do would be to find a map tile source of 'night mode' tiles, and use the MKTileOverlay
class (New to iOS 7) to replace the content of the map entirely.
A brief code example using the Open Street Map tile source (Not night tiles!)
// Put this in your -viewDidLoad method
NSString *template = @"http://tile.openstreetmap.org/{z}/{x}/{y}.png";
MKTileOverlay *overlay = [[MKTileOverlay alloc] initWithURLTemplate:template];
//This is the important bit, it tells your map to replace ALL the content, not just overlay the tiles.
overlay.canReplaceMapContent = YES;
[self.mapView addOverlay:overlay level:MKOverlayLevelAboveLabels];
Then implement the mapView
delegate method below...
- (MKOverlayRenderer *)mapView:(MKMapView *)mapView rendererForOverlay:(id<MKOverlay>)overlay {
if ([overlay isKindOfClass:[MKTileOverlay class]]) {
return [[MKTileOverlayRenderer alloc] initWithTileOverlay:overlay];
}
}
For full reference, see https://developer.apple.com/library/ios/documentation/MapKit/Reference/MKTileOverlay_class/Reference/Reference.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With