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

  • Home
  • SEARCH
  • 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 623661
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T19:07:01+00:00 2026-05-13T19:07:01+00:00

I have been reading thru the documentation however it is not immediatly clear to

  • 0

I have been reading thru the documentation however it is not immediatly clear to me how to draw a polygon using CGPath. All I need to do is to draw CGPath around something like this:

__
\  \ 
 \  \
  \__\

Could anyone please provide an snippet on how to do this?

Additionally I assume CGPathContainsPoint will help me determine if a point is inside such path?, or does the path have to be a solid drawing

Also how can i move the cgpath around? Is this as easy as changing something like the origin just like in cgrect?

Thank you.

-Oscar

  • 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-05-13T19:07:01+00:00Added an answer on May 13, 2026 at 7:07 pm

    You should do it like this:

    - (void)drawRect:(CGRect)rect { 
    
            CGContextRef context = UIGraphicsGetCurrentContext(); 
    
            CGContextSetStrokeColorWithColor(context, [UIColor redColor].CGColor);
            CGContextSetRGBFillColor(context, 0.0, 0.0, 1.0, 1.0);
    
            // Draw them with a 2.0 stroke width so they are a bit more visible.
            CGContextSetLineWidth(context, 2.0);
    
            for(int idx = 0; idx < self.points.count; idx++)
            {
    
                point = [self.points objectAtIndex:idx];//Edited 
                if(idx == 0)
                {
                    // move to the first point
                    CGContextMoveToPoint(context, point.x, point.y);
                }
                else
                {
                    CGContextAddLineToPoint(context, point.x, point.y);
                }
            }
    
            CGContextStrokePath(context);
    }
    

    Note here, the points is the array of points you want to draw the polygon for. So it should be circular path like: You are drawing a triangle of points (x1, x2, x3) then you should pass into array (x1, x2, x3, x1).

    Hope this helps.

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

Sidebar

Related Questions

I have been reading all the Apple documentation on how to handle various events
I have been reading the Phing documentation and it makes sense, but I'm not
I have been reading up on the call stack lately. However all examples and
I have been reading through the documentation on the JavaScriptMVC framework and it looks
I have been reading about bcrypt (application perspective). Thinking of using it to store
I have been reading so many topics here about this, but I could not
I have been reading your posts and they are very helpful. However, I really
I have been reading through the forums that it is not possible to send
I have been reading about tree data structure to model a problem. I need
I have been reading several jQuery tutorials on the web. They all seem very

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.