我基于这段代码:Custom MKAnnotationView with frame,icon and image
我试图做的有点不同......我的图像不透明,我想把图像放在里面。 我的问题是背景图像覆盖了我的图像。所以它看起来像:http://cl.ly/image/0E0S00072G1n
我的代码是这样的:
annotationImageView.image = [UIImage imageNamed:@"marker_fb"];
UIImage *frame = [UIImage imageNamed:@"marker_fb"];
ImagePin *imagePinImage = annotation;
NSString *urlStringForImage = [NSString stringWithFormat:@"%@", imagePinImage.image];
NSURL *urlForImage = [NSURL URLWithString:urlStringForImage];
UIImageView *imageView = [[UIImageView alloc] init];
[imageView setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@", urlForImage]] placeholderImage:[UIImage imageNamed:@"avatar-placeholder.png"]];
UIGraphicsBeginImageContext(CGSizeMake(annotationImageView.image.size.width, annotationImageView.image.size.height));
[frame drawInRect:CGRectMake(0, 0, frame.size.width, frame.size.height)];
[imageView.image drawInRect:CGRectMake(2, 2, 48, 38)]; // the frame your inner image
annotationImageView.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
对象-c中是否存在z-indez?或者我该怎么办? 谢谢。 编辑:我也尝试过:
UIGraphicsBeginImageContextWithOptions(CGSizeMake(annotationImageView.image.size.width, annotationImageView.image.size.height), NO, 0);