あなただけの画像の高さを2倍にすることにより、画像を調整する必要があります。私は点検し、それは完全に働いた。
// Adjust image by doubling the height of the image
- (UIImage *)adjustImage:(UIImage *)image {
CGSize newSize = CGSizeMake(image.size.width, image.size.height * 2);
UIGraphicsBeginImageContextWithOptions(newSize, false, 0);
[image drawInRect:CGRectMake(0,0,image.size.width,image.size.height)];
UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return newImage;
}
- (MGLAnnotationImage *)mapView:(MGLMapView *)mapView imageForAnnotation:(id <MGLAnnotation>)annotation {
MGLAnnotationImage *annotationImage = [mapView dequeueReusableAnnotationImageWithIdentifier:@"driverPinId"];
if (!annotationImage) {
UIImage *image = [UIImage imageNamed:@"DriverPin"];
// The anchor point of an annotation is currently always the center. To
// shift the anchor point to the bottom of the annotation, the image
// asset includes transparent bottom padding equal to the original image
// height.
image = [self adjustImage: image];
// To make this padding non-interactive, we create another image object
// with a custom alignment rect that excludes the padding.
image = [image imageWithAlignmentRectInsets:UIEdgeInsetsMake(0, 0, image.size.height/2, 0)];
// Initialize the ‘DriverPin’ annotation image with the UIImage we just loaded.
annotationImage = [MGLAnnotationImage annotationImageWithImage:image reuseIdentifier:@"driverPinId"];
}
return annotationImage;
}
@riedbunny透明なボトムパッドで新しい画像を作成せずにこれを行うことは可能ですか? – korgx9