NSProgressIndicator and Core Animation

Discussion in 'Mac Programming' started by davbeck, Oct 18, 2009.

  1. macrumors regular

    Joined:
    May 16, 2008
    Location:
    Reno, NV
    #1
    I have a bar style NSProgressIndicator that I am using core animation to fade in when it gets shown. The problem is, that when I set it to layer backed it doesn't animate the progress level (not the fade in, that animates). Also, when I set the value in a background thread, it doesn't update the value visually.

    What is causing this and how do I fix it?
     
  2. Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #2
    Progress indicators don't draw like other views do. I'm not sure exactly how it works, but I'm guessing they draw directly into OpenGL instead of through Quartz. So, this is probably why they won't draw into layers either.

    You can't update UI elements from a background thread. You need to do it in the main thread only.
     
  3. thread starter macrumors regular

    Joined:
    May 16, 2008
    Location:
    Reno, NV
    #3
    It updates and animates just fine when I turn off core animation.
     
  4. macrumors 68030

    Catfish_Man

    Joined:
    Sep 13, 2001
    Location:
    Portland, OR
    #4
    That may "work" most of the time but is not safe to rely on, and may crash or behave oddly in some cases.
     
  5. thread starter macrumors regular

    Joined:
    May 16, 2008
    Location:
    Reno, NV
    #5
    If anybody cares, I had to remove setUsesThreadedAnimation from my code to get it to animate with core animation.
     

Share This Page