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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:13:34+00:00 2026-06-11T00:13:34+00:00

For example, if we are to draw a 100 x 100 pixel circle on

  • 0

For example, if we are to draw a 100 x 100 pixel circle on the main view which covers up the whole screen on the iPad, then instead of using initWithFrame like following 2 steps in viewDidLoad:

UINodeView *nodeView = [[UINodeView alloc] initWithFrame:
                               CGRectMake(x, y, NSNodeWidth, NSNodeHeight)];
nodeView.center = CGPointMake(x, y);

because x and y is more elegantly as self.view.bounds.size.width / 2 to horizontally center the circle, instead of self.view.bounds.size.width / 2 - NSNodeWidth / 2. Is init by a frame first, and then reset the center a good way, or is there a better way, if there is a initWithCenterAndSize?

  • 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-11T00:13:36+00:00Added an answer on June 11, 2026 at 12:13 am

    That’s a fine way of doing it 🙂

    I would have gone for generating the positioned frame first to avoid the extra method call but that’s just a matter of personal preference 🙂

    If you’re using this alot in your app you could make a category on UIView that implements this (warning, untested code 🙂

    - (id)initWithCenter:(CGPoint)point size:(CGSize)size {
        CGRect frame = CGRectMake(point.x-size.width/2,
                                  point.y-size.height/2, 
                                  size.width,
                                  size.height);
        return [self initWithFrame:frame];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to draw a widget (in this example, a canvas) and then remove
For example, I want to draw something directly to an UIView. I need an
I tried the example code in this book to draw the contours in the
Possible Duplicate: Subclassing UIView to draw in Quartz Hello i am searching good example
I want to draw some Rectangle over a single Image . For example I
I want to draw text on canvas., how to do it any sample example?
I'd like to draw some statistics charts using QT4.7 , here are some examples:
I was trying to draw the raphaeljs piechart. I used the same example as
I need to draw a shape then add shadow but shadow is over the
I have a few functions that I'm using to draw different type of text.

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.