iOS Mapkit自定义图像显示放大2倍



我使用下面的图片[使用annotation, MapkitView等]来标记一些位置。但是,当图像显示出来时,它们看起来要大2倍。这正常吗?

这是一个继承类,我使用

@interface ImageAnnotationView : MKAnnotationView {
        UIImageView *_imageView;
        id m_parent;
        BusinessMapAnnotation *m_annotation;
        NSString *stitle;
    }

    - (id)initWithAnnotation:(id <MKAnnotation>)annotation reuseIdentifier:(NSString *)reuseIdentifier
    {
        self = [super initWithAnnotation:annotation reuseIdentifier:reuseIdentifier];
        self.backgroundColor = [UIColor clearColor];
        self.m_annotation = (BusinessMapAnnotation*)annotation;
        self.stitle = m_annotation.sTitle;
        _imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:([stitle isEqualToString:@"You are here"]) ? @"Pushpin_large.png":@"NearPin.png"]];
        _imageView.contentMode = UIViewContentModeCenter;
        [self addSubview:_imageView];
        _imageView.center = ([stitle isEqualToString:@"You are here"]) ? CGPointMake(15.0, -10.0):CGPointMake(kWidth/2, 0.0);
        return self;
    }

如果您的图像是为视网膜显示质量分辨率制作的,但没有将@2x附加到文件名的末尾(即:'Pushpin_large@2x.png'作为您的项目文件夹中的文件名),然后它们将在绘制时显示两倍大。如果是这种情况,不要更改代码,只需将@2x附加到文件名。

最新更新