Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9244433
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T09:01:45+00:00 2026-06-18T09:01:45+00:00

I found out how to draw a cricle around map annotation. I do it

  • 0

I found out how to draw a cricle around map annotation.
I do it like this:

     MKCircle *circle = [MKCircle circleWithCenterCoordinate:theCoordinate radius:15000];
     [myMap addOverlay:circle];

 -(MKOverlayView *)mapView:(MKMapView *)mapView viewForOverlay:(id)overlay
 {
    MKCircleView *circleView = [[MKCircleView alloc] initWithOverlay:overlay];
    circleView.fillColor =[UIColor redColor];

   return circleView;
}

It works ok but i would like to draw a circle whose fill color is not solid like this:

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T09:01:46+00:00Added an answer on June 18, 2026 at 9:01 am

    To draw a circle with a gradient, you have to provide an own annotation view class, as none of the existing ones support that. What you can do is you can override the method - (void)fillPath:(CGPathRef)path inContext:(CGContextRef)context in a subclass of MKCircleView. Here is some code (non-optimized, with hardcoded fill parameters) to get you started:

    @interface TWOGradientCircleView : MKCircleView
    @end
    
    @implementation TWOGradientCircleView
    
    - (void)fillPath:(CGPathRef)path inContext:(CGContextRef)context
    {
        CGRect rect = CGPathGetBoundingBox(path);
    
        CGContextAddPath(context, path);
        CGContextClip(context);
    
        CGFloat gradientLocations[2] = {0.6f, 1.0f};
        // Start color white with 0.25 alpha,
        // End color green with 0.25 alpha
        CGFloat gradientColors[8] = {1.0f, 1.0f, 1.0f, 0.25f, 0.0f, 1.0f, 0.0f, 0.25f};
        CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
        CGGradientRef gradient = CGGradientCreateWithColorComponents(colorSpace, gradientColors, gradientLocations, 2);
        CGColorSpaceRelease(colorSpace);
    
        CGPoint gradientCenter = CGPointMake(CGRectGetMidX(rect), CGRectGetMidY(rect));
        CGFloat gradientRadius = MIN(rect.size.width, rect.size.height) / 2;
    
        CGContextDrawRadialGradient(context, gradient, gradientCenter, 0, gradientCenter, gradientRadius, kCGGradientDrawsAfterEndLocation);
    
        CGGradientRelease(gradient);
    }
    

    To use it, just replace MKCircleView with TWOGradientCircleView:

    - (MKOverlayView *)mapView:(MKMapView *)mapView viewForOverlay:(id)overlay
    {
        MKCircleView *circleView = [[TWOGradientCircleView alloc] initWithOverlay:overlay];
    
        return circleView;
    }
    

    If you would like to use an image instead of drawing the gradient, you can replace the gradient drawing above with image drawing. As zooming in would then blur the image, you should either disable zoom, or tile the image as Apple demonstrated in a session at WWDC10 (see here for a repository with their sample code). Setting a UIColor with a pattern image does not work for a radius of 15000 (unless you use a really, really huge image ;)).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I found out this morning that proc.new works in a class initialize method, but
I am currently trying out restful_authentication in rails. This is my routes.rb file ActionController::Routing::Routes.draw
I found out about GWT's CustomScrollPanel and how you can customize the scroll bar,
I found out that it is possible to open the windows explorer with a
I found out opencv sample face detection example for android but it is detecting
I found out jQuery does not always create the correct DOM from an HTML
I found out during the debug that my db is in: /data/data/package-name/databases/... how can
I found out how to retreive the html page of a topic from google
I found out how to sort a JSON array at http://www.devcurry.com/2010/05/sorting-json-array.html Now I want
I found out an application I wrote does not work properly under Windows Vista/7

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.