Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to use custom view for SKCalloutView?

Is it possible to make a custom UIView, with elements such as Label and Button, and use it as a CalloutView?

What I read through the documentation so far doesn't implicates that it is possible.

Changing left and right button is possible, together with adding custom UIImageView for an arrow, but couldn't figure out if customising entire view is actually possible.

like image 282
SteBra Avatar asked Dec 12 '25 19:12

SteBra


1 Answers

Yes - you just have to override the calloutViewForAnnotation callback. There is an example in the demo project (see inside AnnotationsViewController.m) where you can create a user defined UIView and return that

- (UIView*)mapView:(SKMapView *)mapView calloutViewForAnnotation:(SKAnnotation *)annotation
{
    //Custom callouts.
    if (annotation.identifier == self.annotation1.identifier)
    {
        UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0.0f, 0.0f, 200.0f, 50.0f)];
        view.backgroundColor = [UIColor purpleColor];
        view.alpha = 0.5f;
        return view;
    }

    return nil;// Default callout view will be used.
}
like image 147
Ando Avatar answered Dec 14 '25 12:12

Ando



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!