<bdo id='bwOfI'></bdo><ul id='bwOfI'></ul>
    <legend id='bwOfI'><style id='bwOfI'><dir id='bwOfI'><q id='bwOfI'></q></dir></style></legend>

      <small id='bwOfI'></small><noframes id='bwOfI'>

        <tfoot id='bwOfI'></tfoot>

      1. <i id='bwOfI'><tr id='bwOfI'><dt id='bwOfI'><q id='bwOfI'><span id='bwOfI'><b id='bwOfI'><form id='bwOfI'><ins id='bwOfI'></ins><ul id='bwOfI'></ul><sub id='bwOfI'></sub></form><legend id='bwOfI'></legend><bdo id='bwOfI'><pre id='bwOfI'><center id='bwOfI'></center></pre></bdo></b><th id='bwOfI'></th></span></q></dt></tr></i><div id='bwOfI'><tfoot id='bwOfI'></tfoot><dl id='bwOfI'><fieldset id='bwOfI'></fieldset></dl></div>

        带有框架、图标和图像的自定义 MKAnnotationView

        时间:2023-05-31

        <small id='2hxul'></small><noframes id='2hxul'>

      2. <tfoot id='2hxul'></tfoot>

          <i id='2hxul'><tr id='2hxul'><dt id='2hxul'><q id='2hxul'><span id='2hxul'><b id='2hxul'><form id='2hxul'><ins id='2hxul'></ins><ul id='2hxul'></ul><sub id='2hxul'></sub></form><legend id='2hxul'></legend><bdo id='2hxul'><pre id='2hxul'><center id='2hxul'></center></pre></bdo></b><th id='2hxul'></th></span></q></dt></tr></i><div id='2hxul'><tfoot id='2hxul'></tfoot><dl id='2hxul'><fieldset id='2hxul'></fieldset></dl></div>
            <tbody id='2hxul'></tbody>
                <bdo id='2hxul'></bdo><ul id='2hxul'></ul>

                1. <legend id='2hxul'><style id='2hxul'><dir id='2hxul'><q id='2hxul'></q></dir></style></legend>

                  本文介绍了带有框架、图标和图像的自定义 MKAnnotationView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我一直在寻找类似的解决方案,了解如何设计像这样的自定义 MKAnnotationView.

                  I've been searching for a similar solution on how to design a custom MKAnnotationView like this one.

                  我对 MKAnnotation 进行了子类化,并且能够添加一个名为 F.png 的图像F.png 是如图所示的帧图像.我想要的是添加一个内部图像.(我画的图中是蓝色的)

                  I'v subclassed the MKAnnotation and i was able to add an image named F.png the F.png is a frame image as showed in the picture. what i want is to add an inner image. (colored Blue in the picture i draw)

                  - (MKAnnotationView *)mapView:(MKMapView *)theMapView viewForAnnotation:(id <MKAnnotation>)annotation
                  {    
                  if ([annotation isKindOfClass:[MKUserLocation class]])
                      return nil;
                  static NSString* AnnotationIdentifier = @"AnnotationIdentifier";
                  MKAnnotationView *annotationView = [mapView dequeueReusableAnnotationViewWithIdentifier:AnnotationIdentifier];
                  if(annotationView)
                      return annotationView;
                  else
                  {
                      MKAnnotationView *annotationView = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:AnnotationIdentifier];
                      annotationView.canShowCallout = YES;
                      annotationView.image = [UIImage imageNamed:[NSString stringWithFormat:@"F.png"]];        
                      UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
                      [rightButton addTarget:self action:@selector(writeSomething:) forControlEvents:UIControlEventTouchUpInside];
                      [rightButton setTitle:annotation.title forState:UIControlStateNormal];
                  
                      annotationView.rightCalloutAccessoryView = rightButton;
                      annotationView.canShowCallout = YES;
                      annotationView.draggable = NO;
                      return annotationView;
                  }
                  return nil;
                  }
                  

                  推荐答案

                  在你的代码中

                  else
                  {
                      MKAnnotationView *annotationView = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:AnnotationIdentifier];
                      annotationView.canShowCallout = YES;
                  
                      //change here
                      annotationView.image = [UIImage imageNamed:[NSString stringWithFormat:@"F.png"]];  
                  
                      UIImage *frame = [UIImage imageNamed:[NSString stringWithFormat:@"F.png"];
                      UIImage *image = theImageInFrameInner;
                  
                      UIGraphicsBeginImageContext(CGSizeMake(pin.size.width, pin.size.height));
                  
                      [frame drawInRect:CGRectMake(0, 0, frame.size.width, frame.size.height)];
                      [image drawInRect:CGRectMake(2, 2, 60, 60)]; // the frame your inner image
                      //maybe you should draw the left bottom icon here, 
                  
                      //then set back the new image, done
                      annotationView.image = UIGraphicsGetImageFromCurrentImageContext();
                  
                      UIGraphicsEndImageContext();
                  
                      UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
                      [rightButton addTarget:self action:@selector(writeSomething:) forControlEvents:UIControlEventTouchUpInside];
                      [rightButton setTitle:annotation.title forState:UIControlStateNormal];
                  
                      annotationView.rightCalloutAccessoryView = rightButton;
                      annotationView.canShowCallout = YES;
                      annotationView.draggable = NO;
                      return annotationView;
                  }
                  

                  这篇关于带有框架、图标和图像的自定义 MKAnnotationView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:iOS 5 自定义标签栏图像垂直对齐 下一篇:未知类型名称“类";您指的是 'Class'

                  相关文章

                  最新文章

                  <legend id='GIbdC'><style id='GIbdC'><dir id='GIbdC'><q id='GIbdC'></q></dir></style></legend>

                  1. <tfoot id='GIbdC'></tfoot>
                    • <bdo id='GIbdC'></bdo><ul id='GIbdC'></ul>
                      <i id='GIbdC'><tr id='GIbdC'><dt id='GIbdC'><q id='GIbdC'><span id='GIbdC'><b id='GIbdC'><form id='GIbdC'><ins id='GIbdC'></ins><ul id='GIbdC'></ul><sub id='GIbdC'></sub></form><legend id='GIbdC'></legend><bdo id='GIbdC'><pre id='GIbdC'><center id='GIbdC'></center></pre></bdo></b><th id='GIbdC'></th></span></q></dt></tr></i><div id='GIbdC'><tfoot id='GIbdC'></tfoot><dl id='GIbdC'><fieldset id='GIbdC'></fieldset></dl></div>

                      <small id='GIbdC'></small><noframes id='GIbdC'>