【问题标题】:Custom marker icon iOS bad quality自定义标记图标 iOS 质量差
【发布时间】:2016-03-02 16:54:26
【问题描述】:

我正在尝试将图像添加到标记。如何达到最佳品质?如您所见,Google 地图自己将其增加了两倍。

【问题讨论】:

    标签: ios maps marker


    【解决方案1】:

    您是向项目添加资产还是仅添加一张图片?

    因此,您需要将图像资产(命名为 - bigMarker.png、bigMarker@2x.png、bigMarker@3x.png)添加到您的项目资产中,例如屏幕截图。这在 iOS 9 上运行良好。

    我在 viewDidLoad 中的代码示例:

    // Add custom position in Kansas
    CustomAnnotation *annotation = [CustomAnnotation new];
    annotation.title = @"Elevation Burger";
    annotation.subtitle = @"The best buns...";
    annotation.coordinate = CLLocationCoordinate2DMake(39.0119020f,-98.4842460f);
    [self.myMap addAnnotation:annotation];
    

    还有这个代表:

    - (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation {
    
        MKAnnotationView *annotationView = nil;
        if (annotation != mapView.userLocation) {
            annotationView = [[MKAnnotationView alloc] initWithAnnotation:annotation
                                                          reuseIdentifier:nil];
            annotationView.canShowCallout = YES;
            annotationView.image = [UIImage imageNamed:@"bigMarker"];
            annotationView.leftCalloutAccessoryView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"burgerBitmap"]];
    
            UIButton *accessoryButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
            UIImage *disclosureButtonImage = [[UIImage imageNamed:@"disclosure"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
            [accessoryButton setImage:disclosureButtonImage forState:UIControlStateNormal];
            annotationView.rightCalloutAccessoryView = accessoryButton;
        }
        return annotationView;
    }
    

    【讨论】:

      猜你喜欢
      • 2012-08-10
      • 1970-01-01
      • 2017-03-05
      • 1970-01-01
      • 1970-01-01
      • 2013-09-15
      • 1970-01-01
      • 2015-06-06
      • 1970-01-01
      相关资源
      最近更新 更多