मैं उपवर्गीकरण द्वारा एक कस्टम एनोटेशन दृश्य बनाने के लिए कोशिश कर रहा हूँ MKAnnotationViewऔर अधिभावी drawRectविधि। मैं दृश्य एनोटेशन की स्थिति से ऑफसेट तैयार किया जा करना चाहते हैं, कुछ हद तक पसंद है MKPinAnnotationViewयह होता है, ताकि पिन के बिंदु, निर्दिष्ट निर्देशांक में है बल्कि पिन के बीच से। इसलिए मैं फ्रेम स्थिति और आकार के रूप में नीचे दिखाया गया है निर्धारित किया है। हालांकि, यह नहीं दिखता है जैसे मैं बिल्कुल ही आकार फ्रेम की स्थिति को प्रभावित कर सकते हैं। छवि समाप्त होता है एनोटेशन स्थिति से अधिक किया जा रहा तैयार केन्द्रित। कैसे प्राप्त करने के लिए मैं क्या चाहते हैं पर कोई सुझाव?
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];
}













