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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T12:38:14+00:00 2026-05-30T12:38:14+00:00

In this code CGRect contextRect = self.bounds; will refer which bound? rectangle, imageRect, or

  • 0

In this code

CGRect contextRect = self.bounds;

will refer which bound? rectangle, imageRect, or whole iOS view.

I am trying to manipulate image using quartz2D, i created this code by looking different examples, and code written between // is from Apple Quartz2D guide draw text.

Thanks in advance,
Regards.

    - (void)drawRect:(CGRect)rect
    {
        CGSize cgs = CGSizeMake(250.0, 400.0);
        UIGraphicsBeginImageContext(cgs);

        CGRect rectangle = CGRectMake(0,0,cgs.width,cgs.height);
        CGRect imageRect = CGRectInset(rectangle, 5.4, 5.4);
        imageRect.size.height -= 100;

        UIImage *myImage = [UIImage imageNamed:@"pumpkin.jpg"]; 
        [myImage drawInRect:imageRect];    

        CGContextRef context = UIGraphicsGetCurrentContext();
        CGContextSetLineWidth(context, 10.0);
        CGContextSetRGBStrokeColor(context, 0.0, 0.0, 1.0, 1.0);
        CGContextStrokeRect(context, rectangle);

        //    

        CGRect contextRect = self.bounds;

        CGContextTranslateCTM(context, 0, contextRect.size.height);
        CGContextScaleCTM(context, 1, -1);

        float w, h;
        w = contextRect.size.width;
        h = contextRect.size.height;

        CGAffineTransform myTextTransform;
        CGContextSelectFont (context, "Helvetica-Bold", h/10, kCGEncodingMacRoman);
        CGContextSetCharacterSpacing (context, 10);
        CGContextSetTextDrawingMode (context, kCGTextFillStroke);

        CGContextSetRGBFillColor(context, 0, 1, 0, .5);
        CGContextSetRGBStrokeColor(context, 0, 0, 1, 1);
        myTextTransform =  CGAffineTransformMakeRotation(0);
        CGContextSetTextMatrix(context, myTextTransform);
        CGContextShowTextAtPoint(context, 0, 50, "Quartz 2D", 9);

        //    

        UIImage *testImg =  UIGraphicsGetImageFromCurrentImageContext();
        UIGraphicsEndImageContext();

        [testImg drawAtPoint:CGPointMake(35, 10)];
}
  • 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-30T12:38:16+00:00Added an answer on May 30, 2026 at 12:38 pm

    self.frame indicates the coords and size of the view in its parent view coordinate system.

    self.bounds indicates the coords and size of the view in its own coordinate system. So it always has the same width and height as self.frame, but it has x and y equal to 0.

    self.bounds is equal to CGRectMake(0, 0, self.frame.size.width, self.frame.size.height).

    So your code:

    CGRect contextRect = self.bounds;
    

    is the same as:

    CGRect contextRect = rect;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code: -(void)textFieldDidBeginEditing:(UITextField *)textField { CGRect textFieldRect = [self.view.window convertRect:textField.bounds fromView:textField];
I am using this code: CGRect myRect = CGRectMake(self.frame.size.width, self.frame.size.height); But it gives this
I'm using this code to resize an image on the iPhone: CGRect screenRect =
Whats wrong with this code? -(void) drawRect:(CGRect) rect { CGContextRef c = UIGraphicsGetCurrentContext(); if
Hi all i am using this code in my application. CGRect keyboardBounds = [(NSValue
I have this code- /** Save the web view as a screenshot. Currently only
I fear this is evil code: CGRect iRect = CGRectMake(0.0f, 0.0f, 320.0f, 400.0f); UIImageView
I have this code to rotate CGImage: - (CGImageRef)rotateCGImageRef:(CGImageRef)imageRef toOrientation:(UIImageOrientation)orientation { CGRect bnds =
I am making a application which will show data in table view. I am
I'm using this code to create a rounded cornered image: CGContextBeginPath(context); CGRect rect =

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.