您的位置:首页 > 其它

设置大头针从天而降的效果

2016-02-23 15:21 295 查看
#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;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: