Próbálom, hogy egyéni kommentár nézet alosztály MKAnnotationViewés felülírja a drawRectmódszert. Azt akarjuk, hogy a céllal, hogy levonható tolva a kommentár helyzetét, valahogy úgy, mint MKPinAnnotationViewcsinálja, úgy, hogy a pont a gombostű a megadott koordinátákat, hanem a közepén a csapot. Így hát elindult a keret helyzetét és méretét az alábbiak szerint. Azonban ez nem úgy néz ki, mint én hatással lehet a keret helyzetét egyáltalán, csak a méret. A kép végül is húzott középre a kommentár helyzetbe. Minden tipp, hogyan lehet elérni, amit akarok?
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];
}













