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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:01:35+00:00 2026-05-28T13:01:35+00:00

I am trying to draw in a CALayer subclass. The drawInContext is called with

  • 0

I am trying to draw in a CALayer subclass.
The drawInContext is called with setNeedsDisplay but nothing is drawn.
What am doing/getting wrong here ?

 - (void)drawInContext:(CGContextRef)ctx
{
    CGContextSetFillColorWithColor(ctx, [UIColor redColor].CGColor);
    [[UIBezierPath bezierPathWithRect:CGRectMake(100, 100, 100, 100)] fill];

    [@"Vowel" drawAtPoint:CGPointMake(0, 0) withFont:[UIFont fontWithName:@"Chalkboard" size:14]];
}

Edit
I am getting this error :

CGContextAddPath: invalid context 0x0

Thanks
Shani

  • 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-28T13:01:36+00:00Added an answer on May 28, 2026 at 1:01 pm

    You’re mixing CG calls and UIKit calls. -[UIBezierPath fill] and -[NSString drawAtPoint:withFont:] both draw into the context at the top of the UIKit context stack. That’s not the same thing as the context passed into -drawInContext:. You should modify your function to look like:

    - (void)drawInContext:(CGContextRef)ctx {
        UIGraphicsPushContext(ctx);
        [[UIColor redColor] setFill];
        [[UIBezierPath bezierPathWithRect:CGRectMake(100, 100, 100, 100)] fill];
        [@"Vowel" drawAtPoint:CGPointMake(0, 0) withFont:[UIFont fontWithName:@"Chalkboard" size:14]];
        UIGraphicsPopContext();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to draw a picture to the window but it is only
Greetings! I'm trying to draw a series of circles in a CALayer that resides
I trying to draw custom arc in current context, but the result is not
I'm trying to draw a line segment, but knowing only the origin, the angle,
I am trying to subclass CCSprite but for some reason I can't seem to
I am trying to draw a transparent (alpha) PNG image using CxImage, but it
I'm trying to draw a custom-shaped shadow using CALayer : #import <QuartzCore/QuartzCore.h> @implementation ZKSBAppDelegate
I'm trying to draw an Image with Java, I've the next code: public void
I am trying to draw a line using the Graphics 2D but then the
I'm trying to draw image using UIImage 's drawInRect: method. Here is the code:

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.