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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:20:43+00:00 2026-05-20T11:20:43+00:00

Today I decided to try to use CALayers to show a rectangular box overlaying

  • 0

Today I decided to try to use CALayers to show a rectangular box overlaying a NSView. The layer will contain some text and will be turned on and off depending on when it is necessary to show the variable text. The reason I wanted to use CALayer for this was the nifty rendering and animation you can easily do with CALayer. I implemented my layer and it worked like a charm. However, after using my GUI and clicking several times on various buttons turning the layer on and off, it seemed that the hierarchy of what I thought was my layer view was skewed. I think focus must have been switched to some other NSView which again was turned off. I basically got very confused as to which layer I was handling at a given time and I lost control of the view hierarchy.

My question is: should I use subviews of NSView, or CALayers to show something that may occur many times on and off in an application? It seems to me that it is easy to loose control of which layer you are working on. Is there a way to identify by name the current layer so you can reuse the layer, or is it best to work with layers, delete them and then re-create the layer the next time you need them?

Thanks for your time. Cheers, Trond

  • 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-20T11:20:44+00:00Added an answer on May 20, 2026 at 11:20 am

    FWIW,

    1. I have often turned CALayers “on and off” very quickly, with no problems at all. So you can do that if you want to!

    2. Deleting them and recreating them quickly on the fly, does not seem to cause any problems. (It’s not a big resource user, and I’ve never seen any other problems doing that.) So definitely do that if you want to!

    3. I actually don’t understand what you mean about “naming” layers – of course, as iVars they have a name! You have to name all your CALayers.

    Here’s a typical bit of production code (from a .h file):

    CALayer         *rearLayer;
    CALayer         *hugeBasket;        // holds everything for ez-on/off
    CALayer         *theActualSkyline;  // nb, same name as similar UIView
    CALayer         *someTrees;         // minor stuff
    CALayer         *someBushes;        // overs
    
    // for the stupid help basket..
    CALayer         *LLDRear;
    CALayer         *LLDArrowLeft;
    CALayer         *LLDArrowRight;
    CALayer         *LLDPointlessUpArrow;
    CALayer         *LLDYetAnotherStupidShadow;
    
    // etc etc..
    

    And so on and on. I don’t really see how you can “not” name them, you know!

    Finally,

    4, Don’t forget layers are much “better” than NSViews, because: NSViews have shoddy/buggy relationship between overlapping siblings: they essentially don’t work. Read about that here:
    port an iOS (iPhone) app to mac?

    Hope it helps!

    PS – these may also help with CALayers…

    Exactly what should happen in a CALayer's display/drawRect methods?

    What's the difference and compatibility of CGLayer and CALayer?

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

Sidebar

Related Questions

Yesterday i installed C# 3.5 and today when read topic here of Accessing Google
I've always felt like SecureString was a little odd, but assumed most of my
There is a similar question going around, but it just got the same old
We have a solution that comprises several projects. I came on not too long
I want to know how to call a function, passing a parameter that it
As I'm learning the iPhone API, the book I'm using has me doing everything
As one who is relatively new to the whole support and bug fixing environment
I have a web application written in PHP. It uses MySQL for data storage.
I've never written any tests in my life, but I'd like to start writing
Has anyone written the GNU cat command in python and would be willing to

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.