MapViewのサブビューとしてUIImageViewを追加する必要があります。これを行うために、私はMapViewの上にレイヤーを作成しました。このレイヤーではイメージを入れたいですが、白い矩形などがあります。私のイメージは見えません。CALayerでUIImageを追加
これはコードです:
- (void)viewDidLoad
{
//......
CALayer *layer = [CALayer layer];
layer.backgroundColor = [[UIColor whiteColor] CGColor];
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
{
layer.bounds = CGRectMake(self.mapView.bounds.origin.x,
self.mapView.bounds.origin.y, 80, 300);
}
else
{
layer.bounds = CGRectMake(self.mapView.frame.origin.x,
self.mapView.frame.origin.y, 150, 700);
}
layer.contents = (id)[UIImage imageNamed:@"myImage.png"];
//the name is correct but in the output the image is not visible
[[self.mapView layer] addSublayer:layer];
[layer setNeedsDisplay];
}
私は、setNeedsDisplayがコンテンツを再描画してイメージを削除するようにしたと思います。 – Bastian
これも私の仕事でした。 Adrianaに感謝します。 –