Ios 如何将框架设置为在MapAnnotation上设置的UIImage
我需要将框架设置为一个图像,该图像用作pinAnnotation的图像 这是我添加的图像Ios 如何将框架设置为在MapAnnotation上设置的UIImage,ios,map,Ios,Map,我需要将框架设置为一个图像,该图像用作pinAnnotation的图像 这是我添加的图像 MKAnnotationView* annotationView = [objMapView dequeueReusableAnnotationViewWithIdentifier:annotationIdentifier]; if(!annotationView) { annotationView = [[MKAnnotationView alloc] initWithAn
MKAnnotationView* annotationView = [objMapView dequeueReusableAnnotationViewWithIdentifier:annotationIdentifier];
if(!annotationView)
{
annotationView = [[MKAnnotationView alloc] initWithAnnotation:annotation
reuseIdentifier:annotationIdentifier];
}
annotationView.image = [UIImage imageNamed:@"rrb.png"] ;
当前视图如下所示…而此图像将用于每个annotationPin。
虽然这张图片很大,但我如何设置框架,使其正好符合我的框架。
这些图像将通过Web服务发送
景色应该是这样的。。。(我更改了图像的大小)
要在注释上设置图像,请执行以下操作:
UIImageView *imgV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:joinString]];
[imgV setFrame:CGRectMake(0, 0, 40, 40)];
annotationView.image = imgV.image;
//join String是包含从webService获取的图像的字符串。mapView委托有一个名为的方法。您应该能够通过访问注释视图并将其更改为您喜欢的任何内容来设置注释视图的框架。您可以使用以下方法:
- (MKAnnotationView*)地图视图:(MKMapView*)地图视图注释:(id)注释{
MKAnnotationView*annView=[[MKAnnotationView alloc]initWithAnnotation:annotation重用标识符:nil]
UIImage*image=[UIImage ImageName:@“image.png”];
UIImageView*imageView=[[UIImageView alloc]initWithImage:image];
[annView addSubview:imageView];
[图像视图发布]
MKPinAnnotationView*pinView=[[MKPinAnnotationView alloc]initWithAnnotation:annotation重用标识符:nil];
[annView addSubview:pinView]; [pinView发布] 返回视图; }