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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T17:13:02+00:00 2026-06-07T17:13:02+00:00

I am working on Drawing in iOS, I have my code working, drawing is

  • 0

I am working on Drawing in iOS, I have my code working, drawing is working fine, Now I have implemented undo and redo functions, but what is happening is that, suppose I draw two lines and then press undo button, then the first line drawn is getting Blur, and I am not understanding why its happening, below is my undo code.

–

(void)redrawLine
{
    UIGraphicsBeginImageContext(self.bounds.size);
    [self.layer renderInContext:UIGraphicsGetCurrentContext()];
    NSDictionary *lineInfo = [lineArray lastObject];
    curImage = (UIImage*)[lineInfo valueForKey:@"IMAGE"];
    UIGraphicsEndImageContext();
    [self setNeedsDisplayInRect:self.bounds];
    [self setNeedsDisplay];
}



-(void)undoButtonClicked
{
    if([lineArray count]>0){
        NSMutableArray *_line=[lineArray lastObject];
        [bufferArray addObject:[_line copy]];
        [lineArray removeLastObject];
        drawStep = UNDO;
        [self redrawLine];
    }

}


- (void)drawRect:(CGRect)rect
{

    switch (drawStep) {
        case DRAW:
        {
            [curImage drawAtPoint:CGPointMake(0, 0)];
            CGPoint mid1 = midPoint(previousPoint1, previousPoint2); 
            CGPoint mid2 = midPoint(currentPoint, previousPoint1);
            CGContextRef context = UIGraphicsGetCurrentContext(); 

            [self.layer renderInContext:context];
            CGContextMoveToPoint(context, mid1.x, mid1.y);
            CGContextAddQuadCurveToPoint(context, previousPoint1.x, previousPoint1.y, mid2.x, mid2.y); 
            CGContextSetLineCap(context, kCGLineCapButt);
            CGContextSetLineWidth(context, self.lineWidth);
            CGContextSetStrokeColorWithColor(context, self.lineColor.CGColor);
            CGContextSetAlpha(context, self.lineAlpha);
            CGContextSetAllowsAntialiasing(context, YES);
            CGContextStrokePath(context);            
            [super drawRect:rect];  

        }        
        case UNDO:
        {
            [curImage drawInRect:self.bounds];   
            break;
        }
}

Below is the image of what is happening when undo button is pressed

First Image is before undobutton is clicked and second Image is after undobutton is clicked

Before Undo Button clicked
After Undo Button Clicked

Regards
Ranjit

  • 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-07T17:13:04+00:00Added an answer on June 7, 2026 at 5:13 pm

    Your call to UIGraphicsBeginImageContext is specifying the size of the bitmap in points (i.e. 320×480 for full-screen), but on a device with a retina display, you’d need one that’s the size of the screen in pixels (i.e. 640×960).

    You should be able to call UIGraphicsBeginImageContextWithOptions with scale set to 0.0. From the docs:

    The scale factor to apply to the bitmap. If you specify a value of 0.0, the scale factor is set to the scale factor of the device’s main screen.

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

Sidebar

Related Questions

I am working on kind of drawing program but I have a problem with
I'm playing around with drawing in iOS apps. I have a class that is
I have a working line drawing code going using DrawUserPrimitives I have set up
I'm working on a drawing application with HTML5 (canvas) which works fine besides that
I am working on a drawing project. My code is working perfectly other than
I am drawing content to a UITableViewCell and it is working well, but I'm
I am using CoreGraphics to implement free hand drawing which is working fine for
I am custom drawing text into a custom UITableViewCell, but am struggling in working
I am working on an iOS project that loads UIImages from URLs in a
Working with some CoreText code on iOS and I am confused as to why

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.