本帖最后由 fox_ice 于 2018-1-15 17:16 编辑
- (MAAnnotationView *)mapViewMAMapView *)mapView viewForAnnotationid <MAAnnotation>)annotation { // 自定义坐标 CurrentLocationAnnotation * current = (CurrentLocationAnnotation *)annotation; if ([annotation isKindOfClass:[CurrentLocationAnnotation class]]) { static NSString *reuseIndetifier = @"CustomAnnotationView"; MAAnnotationView *annotationView = [mapView dequeueReusableAnnotationViewWithIdentifier:reuseIndetifier]; if (annotationView == nil) { annotationView = [[MAAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:reuseIndetifier]; } else { while ([annotationView.subviews lastObject] != nil) { [(UIView*)[annotationView.subviews lastObject] removeFromSuperview]; } }
UIButton *btn = [UIFactory initBorderButtonWithFrame:CGRectMake(0,0, 100, 40) title:[NSString stringWithFormat"%@\n%@",[annotation title],[annotation subtitle]] textColor:[UIColor whiteColor] font:systemOfFont(13) cornerRadius:10 bgColor:kNavBarTintColor borderColor:[UIColor groupTableViewBackgroundColor] borderWidth:0.5 tag:current.index target:self actionselector(btnAction]; btn.titleLabel.numberOfLines = 2; annotationView.enabled = YES; annotationView.userInteractionEnabled = YES; [annotationView addSubview:btn];
//annotationView.image = [UIImage imageNamed"mapAddress"]; // 设置为NO,用以调用自定义的calloutView annotationView.canShowCallout = false; // 设置中心点偏移,使得标注底部中间点成为经纬度对应点 annotationView.centerOffset = CGPointMake(0, -18); return annotationView; } return nil; }
|