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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T17:04:20+00:00 2026-05-31T17:04:20+00:00

I want to implement a view having two layers on it. Then i want

  • 0

I want to implement a view having two layers on it. Then i want to do some drawing on these layers separately on press of some buttons.

I have implemented delegate method:

- (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)context

but problem is that this delegate is only fired with [myviewclass setNeedsDisplay] method(not by [mylayer setNeedsDisplay])and then drawLayer gets called for view’s root layer always.

I want it to get called for mylayer with accurate context so that i can do drawing on the specific layer using its context.

Please help how to achieve this.

  • 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-31T17:04:21+00:00Added an answer on May 31, 2026 at 5:04 pm

    You must set the delegate of the layer and implement the delegate method drawLayer:inContext: in it. Otherwise, the layer can’t determine in which object it has to call that method.

    Also, the delegate of the layer can’t be the UIView, so you must use something else as a delegate.

    You can use the view controller for example as the delegate of your layers. First, implement the method drawLayer:inContext: in the view controller. Then, set the view controller as the delegate of your layers.

    - (void)viewDidLoad
    {
        [super viewDidLoad];
        // ...
        self.view.layer1.delegate = self;
        self.view.layer2.delegate = self;
    }
    
    - (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx
    {
        if (layer == self.view.layer1) {
            // ...
        } else if (layer == self.view.layer2) {
            // ..
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to implement a view in an iPhone application that is essentially like
I want to implement a two-pass cache system: The first pass generates a PHP
Still having trouble with this language. Ok, let's say I have two objects. The
Ok, I have been searching thick and thin, and I am having some issues
I'm having some problems displaying a ProgressDialog. I have a method that scrapes information
hi i am having a list view and on click i want to show
I have a table view. in that one row is having different lines for
I have some code that displays a checkmark as the auxiliary view of a
I want to implement ThreeColumnLayout for my web-app. E.g. having NavigationComponent, BookmarkComponent in Left
I want implement in my software solution an VBA editor but in c# 3.0.

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.