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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T09:19:35+00:00 2026-05-20T09:19:35+00:00

UIView creates a window graphics context before a custom drawRect: method is invoked, so

  • 0

UIView creates a window graphics context before a custom drawRect: method is invoked, so inside the method I can get the graphics context. However, it seems that the only way to get a window graphics context in iOS, so I can make a CGLayer object based on a window graphics context only in a custom drawRect: method of a UIView object.

However, I might want a model object to contain a CGLayer object, which is created with the model object itself, and later a lot of views use the layer to draw its content on their own views. One might create a bitmap graphics context to create a CGLayer, but then everything drawn on the screen using the CGLayer object will have characteristics of a bitmap context, as Apple’s documents say that drawing with a CGLayer object is restricted to the type of the graphics context used to create the layer.

So my question is, is it really impossible to create a window graphics context outside drawRect: to make a CGLayer object based on it. Or, is there a better way to create and store a CGLayer object for on-screen drawing that may be shared by multiple views? Or is it a completely bogus idea to have such a shared CGLayer object outside a UIView object for a reason I don’t realize?

  • 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-20T09:19:36+00:00Added an answer on May 20, 2026 at 9:19 am

    Yes, you can create a drawing context for a CALayer from a bitmap.

    But the contents of a CGLayer needs a backing bitmap, since it does not save the symbolic (resolution independent) drawing vectors when drawn into, only the resulting pixels. So either you create the backing bitmap, or you use the one handed you by a UIView, or you recreate/redraw the bits from your own command list when required.

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

Sidebar

Related Questions

I am trying to create a delegate protocol for a custom UIView. Here is
If I have a UIView (or UIView subclass) that is visible, how can I
I have a custom UIView that generates a set of subviews and display them
I have a UIView with a navigation bar. How can I hide the navigation
I have refactored some UIView sub-classes into a static library. However, when using Interface
hi am trying to display a uiview class object in the window but the
I have a UIView that will eventually contain about 2 screens worth of information.
When creating a UIView with a navigation bar in interface builder, the top bar
I made a UIView using Interface Builder with a top bar that has Cancel
I have a UIView with a UITableView for a subview. The UIView has an

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.