Спасибо за пример BadPirate.
Я пытался использовать UIImageview, но я не думаю, что это необходимо.
Мой класс выглядел так
@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.frame = CGRectMake(0, 0, kWidth, kHeight);
self.backgroundColor = [UIColor clearColor];
self.m_annotation = (BusinessMapAnnotation*)annotation;
NSString* categoryTitle = m_annotation.sCTitle;
NSString* l_titleString = @"NearPin.png";
if (categoryTitle!= nil ) {
if ([categoryTitle length] > 0) {
//NSLog(@"%@", categoryTitle);
l_titleString = [NSString stringWithFormat:@"Map%@.png", categoryTitle];
//NSLog(@"%@", l_titleString);
}
}
self.stitle = m_annotation.sTitle;
_imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:([stitle isEqualToString:@"You are here"]) ? @"Pushpin_large.png":l_titleString]];
_imageView.contentMode = UIViewContentModeCenter;
_imageView.frame = CGRectMake(kBorder, kBorder, kWidth, kHeight);
[self addSubview:_imageView];
_imageView.center = ([stitle isEqualToString:@"You are here"]) ? CGPointMake(15.0, -10.0):CGPointMake(kWidth/2, 0.0);
return self;
}