Tôi hiển thị hình ảnh đại diện người dùng trên MapView. Các avatar dường như đang hoạt động nếu chúng được hiển thị mà không có hoạt hình, tuy nhiên tôi muốn tạo hiệu ứng cho hoạt ảnh của chúng. Nếu tôi đặt pinView.animatesDrop thành true, thì tôi sẽ mất hình đại diện và nó được thay thế bằng ghim. Làm thế nào tôi có thể tạo hiệu ứng thả hình đại diện của tôi mà không cần sử dụng ghim?MKPinAnnotationView hình ảnh tùy chỉnh được thay thế bằng pin với hoạt hình thả
Đây là phương pháp viewForAnnotation của tôi, tôi đang sử dụng:
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation {
if ([annotation isKindOfClass:[MKUserLocation class]])
return nil;
MKPinAnnotationView* pinView = (MKPinAnnotationView*)[self.mapView dequeueReusableAnnotationViewWithIdentifier:@"MyAnnotation"];
if (!pinView) {
pinView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"CustomPinAnnotation"];
}
else
pinView.annotation = annotation;
//If I set this to true, my image is replaced by the pin
//pinView.animatesDrop = true;
//I'm using SDWebImage
[pinView setImageWithURL:[NSURL URLWithString:@"/pathtosomeavatar.png"] placeholderImage:[UIImage imageNamed:@"placeholder.png"]];
//Adding a nice drop shadow here
pinView.layer.shadowColor = [UIColor blackColor].CGColor;
pinView.layer.shadowOffset = CGSizeMake(0, 1);
pinView.layer.shadowOpacity = 0.5;
pinView.layer.shadowRadius = 3.0;
return pinView;
}
Vui lòng xem http://stackoverflow.com/questions/9814988/mkmapview-instead-of-annotation-pin-a-custom-view – Anna
Liên kết của Anna trả lời câu hỏi của tôi. http://stackoverflow.com/questions/9814988/mkmapview-instead-of-annotation-pin-a-custom-view –
Anna, hãy bình luận của bạn một câu trả lời để tôi có thể cung cấp tín dụng cho bạn. –