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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T03:22:24+00:00 2026-06-12T03:22:24+00:00

This code appears to do nothing. Build successful, no errors. No rectangle drawn on

  • 0

This code appears to do nothing. Build successful, no errors. No rectangle drawn on screen.

- (void)viewDidLoad
{

    [super viewDidLoad];

    UIColor *reliantMagenta             = [UIColor colorWithRed:208.0f / 255.0f green:27.0f / 255.0f blue:124.0f / 255.0f alpha:1];

    CALayer *reliantCanvasLayer         = [CALayer layer];

    reliantCanvasLayer.frame            = CGRectMake(0, 0, 640, 960);

    [[[self view] layer] addSublayer:reliantCanvasLayer];

    CGContextRef ctx                    = UIGraphicsGetCurrentContext();
    CGRect leftRect                     = CGRectMake(0, 0, 200, 300);

    CGContextSaveGState(ctx);
    CGContextSetFillColorWithColor(ctx, reliantMagenta.CGColor);

    CGContextFillRect(ctx, leftRect);
    CGContextRestoreGState(ctx);

}

I am just learning Quartz and really thrashing with it. If you want to explain the relationship between UIViews, CALayers, CGLayers, and context that would be a big help too, but not required, just having trouble understanding what is going on.

  • 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-12T03:22:25+00:00Added an answer on June 12, 2026 at 3:22 am

    If you’re starting out with Quartz, then you should start with the Quartz 2D Programming Guide, which walks through all of this. Your key mistake here is that there is no context available in viewDidLoad. Drawing of this kind is generally done in drawRect:. Your call to UIGraphicsGetCurrentContext() returns NULL at this point.

    After reading through the Programming Guide, you may have more questions, but that’s where you should start to learn about custom drawing.

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

Sidebar

Related Questions

I have this code in Raphael: var myrect = paper.rect(10,10, 25,25); The rectangle appears.
My application is suspending on a line of code that appears to have nothing
I'm trying to run this code but this error appear: Uncaught TypeError: string is
This code below allows me to find the word error in all my files
This code is the core of a much larger script that works great in
This code disabled mouse scroll functionality, when i click on the document. $(document).on(click, function
This code only renders a dodecahedron and completely ignores the glBegin(GL_TRIANGLES) block: glutSolidDodecahedron(); glBegin(GL_TRIANGLES);
This code gives me this error:Cannot implicitly convert type ArrayList[] to ArrayList[][] at this
This code fails on some machines: // Parse error: syntax error, unexpected '[' ...
This code : http://jsfiddle.net/bYtTG/1/ Works as I want in FF, chrome and opera, but

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.