How can I trigger Core Animation on an animator proxy during a call to resizeSubviewsWithOldSize?

StackOverflow https://stackoverflow.com/questions/114970

  •  02-07-2019
  •  | 
  •  

Question

I have some NSViews that I'm putting in one of two layouts depending on the size of my window.

I'm adjusting the layout when the relevant superview receives the resizeSubviewsWithOldSize method.

This works, but I'd like to animate the change. So naturally I tried calling the animator proxy when I set the new frames, but the animation won't run while the user is still dragging. If I release the mouse before the animation is scheduled to be done I can see the tail end of the animation, but nothing until then. I tried making sure kCATransactionDisableActions was set to NO, but that didn't help.

Is it possible to start a new animation and actually have it run during the resize?

Was it helpful?

Solution

I don't think you can do this easily because CA's animations are run via a timer and the timer won't fire during the runloop modes that are active while the user is dragging.

If you can control the runloop as the user is dragging, play around with the runloop modes. That'll make it work. I don't think you can change it on the CA side.

OTHER TIPS

This really isn't an answer, but I would advise against animating anything while dragging to resize a window. The screen is already animating (from the window moving) - further animations are likely going to be visually confusing and extraneous.

CoreAnimation effects are best used to move from one known state to another - for example, when a preference window is resizing to accompany a new pane's contents, and you know both the old and new sizes, or when you are fading an object in or out (or both). Doing animation while the window is resizing is going to be visually confusing and make it harder for the user to focus on getting the size of the window where they want it to be.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top