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 8789605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:27:17+00:00 2026-06-13T22:27:17+00:00

I am drawing a shape like following : – (void)drawRect:(CGRect)rect { // Draw a

  • 0

I am drawing a shape like following :

- (void)drawRect:(CGRect)rect
{
    // Draw a cross rectagle
    CGContextRef    context     =   UIGraphicsGetCurrentContext();
    CGContextSaveGState(context);
    CGContextMoveToPoint(context, 190, 0);
    CGContextAddLineToPoint(context, 220, 0);
    CGContextAddLineToPoint(context, 310, 90);
    CGContextAddLineToPoint(context, 310, 120);
    CGContextSetFillColorWithColor(context, [UIColor lightGrayColor].CGColor);
    CGContextFillPath(context);
    CGContextRestoreGState(context);
}

I am getting a light-dark cross flag below

enter image description here

Now I would like to draw a stroke around the cross flag I have just drawn

What should I do to achieve this. Please advice me on this issue.
Thanks.

  • 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-13T22:27:19+00:00Added an answer on June 13, 2026 at 10:27 pm

    Surely CGContextDrawPath(context, kCGPathFillStroke); is what you’re after

    You can adjust the pattern and color using:

    CGContextSetStrokePattern
    CGContextSetStrokeColor
    

    https://developer.apple.com/library/ios/#documentation/graphicsimaging/reference/CGContext/Reference/reference.html

    So, in your case, assuming you want a plain black stroke, you’d have:

    - (void)drawRect:(CGRect)rect
    {
        CGContextRef    context     =   UIGraphicsGetCurrentContext();
        CGContextSaveGState(context);
    
        CGContextSetLineWidth(context, 2.0);
        CGContextSetStrokeColorWithColor(context, [UIColor blackColor].CGColor);
        CGContextSetFillColorWithColor(context, [UIColor lightGrayColor].CGColor);
    
        CGContextMoveToPoint(context, 190, 0);
        CGContextAddLineToPoint(context, 220, 0);
        CGContextAddLineToPoint(context, 310, 90);
        CGContextAddLineToPoint(context, 310, 120);
        CGContextClosePath(context);
    
        CGContextDrawPath(context, kCGPathFillStroke);
        CGContextFillPath(context);
    
        CGContextRestoreGState(context);
    }
    

    Produces:

    Reminds me of Kraftwork! Result of drawRect:

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

Sidebar

Related Questions

Consider: function Shape() { this.name = "Generic"; this.draw = function() { return "Drawing "
I have a UITableViewCell drawn using drawRect: . I'm drawing an shape in drawRect
I am drawing a shape with a stroke around it by doing following -
I am new to Gtk and want to do simple drawing of shapes like
I'm wondering how vector drawing in Android with the Shape class may resemble another
I want to pass a Shape object to ShapeImp object like Vector or Raster.
Using .NET's System.Drawing.Graphics GDI stuff, I have a shape consting of two arrays of
i have the following situation: one drawing layer (graphics object with lineTo, etc.) one
Is there any easy way to create a shape like a rhombus in raphael
I'm drawing an oblong 'egg' shape (on iOS), and want to use it as

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.