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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T10:02:59+00:00 2026-06-06T10:02:59+00:00

A bit of a newbie question for iOS, just started learning about Core Graphics

  • 0

A bit of a newbie question for iOS, just started learning about Core Graphics but I’m still not sure how it’s integrated into the actual view

So I have a method that creates a CGLayer ref, draws some bezier curves on it, and then returns the CGLayer; here’s a very condensed version of my procedure:

CGContextRef ctx = UIGraphicsGetCurrentContext();
CGLayerRef layer = CGLayerCreateWithContext(ctx, CGSizeMake(300.0,300.0), NULL);
CGContextRef layerCtx = CGLayerGetContext(layer);

Then I add some bezier fills that are dynamically generated by parsing an SVG file.

I’ve already verified that the SVG is being parsed properly, and I am using this code http://ponderwell.net/2011/05/converting-svg-paths-to-objective-c-paths/ to parse the path instructions (from the path tags’ d parameters) into UIBezierPath objects

So I start by creating the fill

CGColorRef color = [UIColor colorWithRed:red green:green blue:blue alpha:1.0].CGColor;
CGContextSetFillColorWithColor(layerCtx, color);

Then adding the UIBezierPath

SvgToBezier *bezier = [[SvgToBezier alloc] initFromSVGPathNodeDAttr:pathAttr rect:CGRectMake(0, 0, 300, 300)];

UIBezierPath *bezierPath = bezier.bezier;

CGContextAddPath(layerCtx, bezierPath.CGPath);
CGContextDrawPath(layerCtx, kCGPathFill);

And finally I return the CGLayerRef like so

return layer;

My question: Now that I have this layer ref, I want to draw it to a UIView (or whatever type of object would be best to draw to)

The ultimate goal is to have the layer show up in a UITableViewCell.

Also, the method I’ve described above exists in a class I’ve created from scratch (which inherits from NSObject). There is separate method which uses this method to assign the layer ref to a property of the class instance.

I would be creating this instance from the view controller connected to my table view. Then hopefully adding the layer to a UITableView cell within the “cellForRowAtIndexPath” method.

I hope I included all of the relevant information and I greatly appreciate your help.

Cheers

  • 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-06T10:03:00+00:00Added an answer on June 6, 2026 at 10:03 am

    Short answer is the view you want to draw on’s layer needs to be set to your newly created layer.

    [myCurrentViewController.view setLayer:newLayer];
    

    Long answer can be found in the excellent Quartz2D programming guide, found here.

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

Sidebar

Related Questions

This may be a bit of a newbie question, but I just don't know!
this is a bit of a newbie question but hoping I can get some
Ok bit of a newbie type question. I want to use Core Data, together
Here's a bit of a newbie Python question about instance variables. Consider the following
I think the question is a bit silly, but for a newbie startup building
I'm learning c++, and I'm a bit of a newbie. I've researched this question
Bit of a newbie question as Im getting started with nHibernate. What's the difference
Just starting with php and sorry if this is a newbie question but i'm
Maybe a bit of a newbie question, but I don't want to mess up
I know this is a bit of a newbie question, but are there equivalents

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.