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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T12:48:44+00:00 2026-05-15T12:48:44+00:00

Given that drawRect takes a CGRect ‘rect’, how can I create 4 separate CGFloat

  • 0

Given that drawRect takes a CGRect ‘rect’, how can I create 4 separate CGFloat variables with the individual values of rect (x,y,width,height)? I need to use the variables on an individual basis to determine certain drawing scales within the drawRect method.

- (void)drawRect:(CGRect)rect {
 CGFLoat x = ***x value of rect***;
 CGFLoat y = ***y value of rect***;
 CGFloat width = ***width value of rect***;
 CGFloat height = ***height value of rect***;
 }

Thanks in advance for your help!

  • 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-15T12:48:45+00:00Added an answer on May 15, 2026 at 12:48 pm

    I’d suggest you brush up on some basic C materials as the question is pretty basic C structure stuff (no big deal — we were all there once).

    Given:

    struct CGPoint {
      CGFloat x;
      CGFloat y;
    };
    typedef struct CGPoint CGPoint;
    
    /* Sizes. */
    
    struct CGSize {
      CGFloat width;
      CGFloat height;
    };
    typedef struct CGSize CGSize;
    
    /* Rectangles. */
    
    struct CGRect {
      CGPoint origin;
      CGSize size;
    };
    typedef struct CGRect CGRect;
    

    You want:
    – (void)drawRect:(CGRect)rect {
    CGFLoat x = rect.origin.x;
    CGFLoat y = rect.origin.y;
    CGFloat width = rect.size.width;
    CGFloat height = rect.size.height;
    }

    Or, better yet, because there are functions for such madness:

    - (void)drawRect:(CGRect)rect {
         CGFLoat x = CGRectGetMinX(rect);
         CGFLoat y = CGRectGetMinY(rect);
         CGFloat width = CGRectGetWidth(rect);
         CGFloat height = CGRectGetHeight(rect);
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given that EVAL is Evil how do I create an Array name dynamically: I
I have a custom UIView class, and in the - (void)drawRect:(CGRect)rect I want to
I have a custom UIView which draws a path like so - (void)drawRect:(CGRect)rect{ [[UIColor
Given that a ThreadLocal variable holds different values for different threads, is it possible
given that I can add various attributes to the stock membership provider I assume
given that a n-byte array can be represented as a 2*n character string using
Given that indexing is so important as your data set increases in size, can
Given that the web application doesn't have su privileges, I'd like to execute a
Given that an input String may be specified as follows: read(xpath(‘...’)) or xpath(‘...’) or
Given that I have a Foo model w/ the standard Rails timestamp columns what

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.