Allow tapping anywhere on an annotation callout without a callout accessory view

前端 未结 5 1558
情歌与酒
情歌与酒 2020-12-28 16:35

I have a map view that adds annotations more or less like this:

- (MKAnnotationView *)mapView:(MKMapView *)mapView
            viewForAnnotation:(id 

        
5条回答
  •  不思量自难忘°
    2020-12-28 17:16

    Try to set custom image for button without changing UIButtonTypeDetailDisclosure type.

    UIButton *detailButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];        
    [detailButton setImage:[UIImage imageNamed:@"icon"] forState:UIControlStateNormal];
    

    For iOS7 and above this image will be tinted by default. If you want to keep original icon use the following

    [[UIImage imageNamed:@"icon"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]
    

    Or if you want to remove icon at all

    [detailButton setImage:[UIImage new] forState:UIControlStateNormal];
    

提交回复
热议问题