ios - 自定义标记图标 iOS 质量差

标签 ios maps marker

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

map

最佳答案

您是向项目添加 Assets 还是只添加一张图片?

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

Assets.xcassets in project bigMarker asset

我在 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];

委托(delegate)中的这个:

- (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;
}

关于ios - 自定义标记图标 iOS 质量差,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35753452/

相关文章:

java - 查找多个键是否映射到相同的值

javascript - 传单是否可以使用多色折线

java - java 中的制图和路线图

matplotlib - 使用比数据点更少的标记进行绘图(或绘制 CDF 的更好方法?)[matplotlib,或一般绘图帮助]

java - 标记未显示在谷歌地图上

javascript - 如何去除传单中的一层

ios - 如何根据 Realm 中的特定属性更新 Realm 对象?

ios - 通过传入字典数组的 init() 方法实例化对象时出现问题

ios - 如何比较两个在 iOS 中具有几乎相同阴影或范围的 UIColor?

iphone - "do not backup"iOS 5.0.1 扩展属性