PDA

View Full Version : NSProgressIndicator and Core Animation




davbeck
Oct 18, 2009, 05:56 PM
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?



kainjow
Oct 18, 2009, 08:32 PM
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).

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.

Also, when I set the value in a background thread, it doesn't update the value visually.

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

davbeck
Oct 18, 2009, 08:40 PM
It updates and animates just fine when I turn off core animation.

Catfish_Man
Oct 18, 2009, 08:53 PM
That may "work" most of the time but is not safe to rely on, and may crash or behave oddly in some cases.

davbeck
Oct 21, 2009, 05:04 PM
If anybody cares, I had to remove setUsesThreadedAnimation from my code to get it to animate with core animation.