に CI フィルターを適用する方法はありますMKMapViews
か? それとも似たようなもの?地図ベースのアプリがベージュに見えないようにしています。RGBA
フィルターを適用する方法はありますか?
ヘルプ/チュートリアルの指示をいただければ幸いです。の変更について説明しているネイティブ ドキュメントには何も表示されませんMKMapView
。
に CI フィルターを適用する方法はありますMKMapViews
か? それとも似たようなもの?地図ベースのアプリがベージュに見えないようにしています。RGBA
フィルターを適用する方法はありますか?
ヘルプ/チュートリアルの指示をいただければ幸いです。の変更について説明しているネイティブ ドキュメントには何も表示されませんMKMapView
。
画面にレンダリングされる前に画像を変更することはできないと思います。ただし、同じ効果を達成する全世界で MKOverlayView を使用できます。以下は機能するはずですが、開始するためだけに疑似コードのように扱ってください。
@interface MapTileOverlay : NSObject <MKOverlay>
@end
@implementation MapTileOverlay
-(id)init {
self = [super init];
if(self) {
boundingMapRect = MKMapRectWorld;
coordinate = MKCoordinateForMapPoint(MKMapPointMake(boundingMapRect.origin.x + boundingMapRect.size.width/2, boundingMapRect.origin.y + boundingMapRect.size.height/2));
}
return self;
}
@end
@interface MapTileOverlayView : MKOverlayView
@end
@implementation MapTileOverlayView
-(void)drawMapRect:(MKMapRect)mapRect zoomScale:(MKZoomScale)zoomScale inContext:(CGContextRef)context {
CGContextSetBlendMode(context, kCGBlendModeMultiply); //check docs for other blend modes
CGContextSetRGBFillColor(context, 1.0, 1.0, 1.0, 0.5); //use whatever color to mute the beige
CGContextFillRect(context, [self rectForMapRect:mapRect]);
}
@end
MKMapViewDelegate
ビューを作成するには、プロトコルを実装するクラスが必要です...
@interface MapViewDelegate : NSObject<MKMapViewDelegate>
@end
@implementation MapViewDelegate
-(MKOverlayView*)mapView:(MKMapView*)mapView viewForOverlay:(id<MKOverlay>)overlay {
if([overlay isKindOfClass:[MapTileOverlay class]]) {
return [[MapTileOverlayView alloc] initWithOverlay:overlay];
}
return nil;
}
最後に、マップを初期化した後、マップにデリゲートを設定してオーバーレイを追加する必要があります...オーバーレイを追加する前にデリゲートを設定する必要があります...
MapViewDelegate* delegate = [[MapViewDelegate alloc] init]; //you need to make this an iVar somewhere
[map setDelegate:delegate];
[map addOverlay:[[MapTileOverlay alloc] init]];
マップ ビューの上にビューを追加できます。ほぼ透明で、わずかに色がついています (たとえば、茶色を補うために青みがかっています)。