设置大头针从天而降的效果
#pragma -mark 设置大头针从天而降的效果
-(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation{
if ([annotation isKindOfClass:[BVAnnotation class]]) {
MKPinAnnotationView *pinAnnotationView = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:@"pin"];
if (pinAnnotationView == nil) {
pinAnnotationView = [[MKPinAnnotationView alloc]initWithAnnotation:annotation reuseIdentifier:@"pin"];
// 设置详情视图的显示
pinAnnotationView.canShowCallout = YES;
// 设置系统大头针的颜色
pinAnnotationView.pinTintColor = [UIColor greenColor];
// 设置从天而降的效果
pinAnnotationView.animatesDrop = YES;
}
pinAnnotationView.annotation = annotation;
// 设置大头针的背景图片(这种方式没有效果)
pinAnnotationView.image = ((BVAnnotation *)annotation).image;
// 可以在大头针上添加一个imageView 来覆盖系统的大头针的样子
UIImageView *imageV =[[UIImageView alloc]initWithFrame:pinAnnotationView.bounds];
imageV.image = ((BVAnnotation *)annotation).image;
// 设置图片和系统的大头针的位置偏移
imageV.left = pinAnnotationView.left+4;
[pinAnnotationView addSubview:imageV];
return pinAnnotationView;
}
return nil;
}
posted on 2016-02-23 15:21 2015ztlucky 阅读(196) 评论(0) 编辑 收藏 举报