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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:26:08+00:00 2026-06-13T07:26:08+00:00

How can I redraw a stored CGPath as a Bezier path if the original

  • 0

How can I redraw a stored CGPath as a Bezier path if the original CGPoints were not stored?

This is the code, but it does not work (the path is redrawn in standard mode rather than in Bezier mode):

CGMutablePathRef UpathFREEHAND = CGPathCreateMutable();
CGPoint firstPointFH = [[pointArray objectAtIndex:0] CGPointValue];
CGPathMoveToPoint(UpathFREEHAND, NULL, firstPointFH.x, firstPointFH.y);

for (int i = 0; i < [pointArray count]; i++)
    {
        CGPathAddLineToPoint(UpathFREEHAND, NULL, [[pointArray objectAtIndex:i] CGPointValue].x, 
        [[pointArray objectAtIndex:i] CGPointValue].y);
    }

CGMutablePathRef _TempPathForUndo = UpathFREEHAND;

//Add PATH object to array
[UPath addObject:CFBridgingRelease(_TempPathForUndo)];

//Load PATH object from array
_TTempPathForUndo = (__bridge CGMutablePathRef)([UPath objectAtIndex:i]);

// Now create the UIBezierPath object.
UIBezierPath *bp;
bp = [UIBezierPath bezierPath];
bp.CGPath = _TTempPathForUndo;

CGContextAddPath(context, bp.CGPath);
//Color, Brush Size parameters, Line cap parameters..
CGContextStrokePath(context);
  • 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-13T07:26:10+00:00Added an answer on June 13, 2026 at 7:26 am

    You can use the following method from UIBezierPath:

    + (UIBezierPath *)bezierPathWithCGPath:(CGPathRef)CGPath
    

    The reuse of a CGPath is valid. Check this example adding TestView in a UIViewController and linking a UIButton to force the redraw when clicking on it with [_testView setNeedsDisplay]:

    // TestView.h
    
    #import <UIKit/UIKit.h>
    
    @interface TestView : UIView {
    
        CGMutablePathRef _path;
        BOOL _nextDraws;
    }
    
    @end
    
    // TestView.m
    
    #import "TestView.h"
    
    @implementation TestView
    
    - (void)drawRect:(CGRect)rect {
    
        BOOL firstDraw = !_nextDraws;
        CGContextRef ctx = UIGraphicsGetCurrentContext();
    
        if (firstDraw) {
            NSLog(@"first draw");
    
            _path = CGPathCreateMutable();
            CGPathMoveToPoint(_path, NULL, 0, 0);
            CGPathAddLineToPoint(_path, NULL, CGRectGetMaxX(rect), CGRectGetMaxY(rect));
            CGPathCloseSubpath(_path);
            CGContextAddPath(ctx, _path);
            CGContextSetStrokeColorWithColor(ctx,[UIColor whiteColor].CGColor);
            CGContextStrokePath(ctx);
    
            _nextDraws = YES;
        }
        else {
            NSLog(@"next draws");
    
            CGContextRef ctx = UIGraphicsGetCurrentContext();
            CGContextClearRect(ctx, rect);
            UIBezierPath * bezierPath = [UIBezierPath bezierPathWithCGPath:_path];
            CGContextAddPath(ctx, bezierPath.CGPath);
            CGContextSetStrokeColorWithColor(ctx,[UIColor whiteColor].CGColor);
            CGContextStrokePath(ctx);
        }
    }
    
    - (void)dealloc {
        CGPathRelease(_path);
        [super dealloc];
    }
    
    @end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to implement redraw regions with up to 3 regions but can't
I can't seem to get the .enter() and .exit for a path to work
Can someone thoroughly explain the last line of the following code: def myMethod(self): #
Can anyone explain to me why this program: for(float i = -1; i <
I don't know if this question has duplicates , but i haven't found one
I am experiencing redraw issues in Chrome that I can't explain. They don't appear
I can successfully compiled and run the Hello World code. Now I want to
I want to make an application in which I can draw a path on
Can anybody tell me what is wrong with my window creation? This function is
i tired to look over SF for solution, but can't find a solution. maybe

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.