设置大头针从天而降的效果
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;
}
-(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;
}
相关文章推荐
- 工业4.0时代,您需要的是高性价工业物联网智能网关(超高性价比),PLC远程监控,PLC远程维护,系统数据采集,一个都不能少。
- 不可不知的HTML优化技巧
- Linux inode
- 互联网医疗模式瞎想
- MFC使用VLD检测内存泄漏
- swift-控制流程04-控制转移语句
- sc.exe
- Android开发之获取系统版本号
- SVN的使用
- 2300: [HAOI2011]防线修建 set维护凸包
- VC内存泄露检查工具:Visual Leak Detector
- irqbalance 服务
- Android Studio安装与配置
- 排颜色问题——数组 leetcode lintcode
- KVO详解
- Android性能优化总结
- 利用python搭建一个简单的http服务器
- 《剑指offer》-用两个栈实现队列
- BZOJ 3196: Tyvj 1730 二逼平衡树|线段树套平衡树
- javascript面试题_1