MKAnnotationView
을 서브 클래 싱하고 drawRect
메서드를 오버라이드하여 사용자 정의 주석보기를 만들려고합니다. 주석 위치에서 오프셋을 그려야합니다. 다소 MKPinAnnotationView
과 같으므로 핀의 포인트는 핀의 중간이 아니라 지정된 좌표에 있습니다. 그래서 아래와 같이 프레임 위치와 크기를 설정합니다. 그러나 프레임의 위치에 전혀 영향을 줄 수없는 것처럼 보입니다. 크기 만 있습니다. 이미지가 주석 위치의 중앙에 그려집니다. 내가 원하는 것을 얻는 방법에 대한 조언?커스텀 MKAnnotationView의 프레임 위치는 어떻게 변경합니까?
MyAnnotationView.h :
@interface MyAnnotationView : MKAnnotationView {
}
MyAnnotationView.m :
- (id)initWithAnnotation:(id <MKAnnotation>)annotation reuseIdentifier:(NSString *)reuseIdentifier {
if (self = [super initWithAnnotation:annotation reuseIdentifier:reuseIdentifier]) {
self.canShowCallout = YES;
self.backgroundColor = [UIColor clearColor];
// Position the frame so that the bottom of it touches the annotation position
self.frame = CGRectMake(0, -16, 32, 32);
}
return self;
}
- (void)drawRect:(CGRect)rect {
[[UIImage imageNamed:@"blue-dot.png"] drawInRect:rect];
}
예에서
답변. 그러나 나는 여전히 일반적인 경우에 대해 궁금해. – andrei