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

  • Home
  • SEARCH
  • 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 8221123
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T13:47:35+00:00 2026-06-07T13:47:35+00:00

How do I create a CGImage from UIView Subclass? Should I use renderInContext:UIGraphicsGetCurrentContext() to

  • 0

How do I create a CGImage from UIView Subclass?

Should I use renderInContext:UIGraphicsGetCurrentContext() to create a CG image from a view (subclass of UIView) that contains a drawing (core graphics via drawRect method)?

I have an view, myView, in which I am doing some drawing. I want to do some other core graphics operations with the drawing I have created – like blend modes etc with imported photos, so I need to get a CGimage from myView I assume. Not finding a CGImage property (my first guess). Poking around I found the solution below, but my subclass “does not declare the selector renderInContext”, so I get an error.

UIGraphicsBeginImageContext(myView.bounds.size);
[myView renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

CGImageRef cgImage = image.CGImage;
  • 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-07T13:47:39+00:00Added an answer on June 7, 2026 at 1:47 pm

    -renderInContext: is a method on CALayer, not UIView.

    Do this instead:

    [myView.layer renderInContext:UIGraphicsGetCurrentContext()];
    

    You will also need to import the headers for CALayer:

     #import <QuartzCore/QuartzCore.h>
    

    And link your app against the QuartzCore framework.

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

Sidebar

Related Questions

So I'd like to create a class that accepts a CGImage from an image
The problem: On top of existing UIView, load a background image From the card
Loading a CGImage or NSImage from a file using a standard image format (jpeg,
I am trying to create a new Image from raw data in unsigned char
I am trying to create CGImage from NSTextField. I got some success in this.
I am trying to to pixel-by-pixel image filters using Core Graphics (breaking a CGImage
Create Pex test to test a DLL and hardware controlled by that DLL? I
I am working on an iOS project that loads UIImages from URLs in a
I have array with colors as its objects. I want to create an image
Slower than what? slower than creating the same textures from an image loaded from

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.