Question

I want to make a view move to a different position on window resize. I currently do this with NSViewAnimation on receiving the NSWindowDidResizeNotification.

// Create the view animation object.
theAnim = [[NSViewAnimation alloc] initWithViewAnimations:animation];
// Set some additional attributes for the animation.
[theAnim setDuration:1];    // One and a half seconds.
[theAnim setAnimationCurve:NSAnimationEaseIn];
[theAnim setFrameRate:20.0];
[theAnim setAnimationBlockingMode:NSAnimationNonblocking];
// Run the animation.
[theAnim startAnimation];
// The animation has finished, so go ahead and release it.
[theAnim release]; 

("animation" is an array with a dict containing a new rect for my view like NSAnimation wants it) This code is called multiple times when I resize the window. So on resizing this code gets called about 20 times for one resize. I now have 20 animations of the view moving. 20 different ones overlapping. (It looks like many different views but I think its the same one hopping between animations)

On the iPhone there would be only the view moving and i could set [UIView setAnimationBeginsFromCurrentState:YES] and it would work. Is there a way to do this on OSX? I could create a isAnimating variable on the view but then it would move to one position only and would ignore a quick resize while animating.

How do I do this on OSX? Thanks

Was it helpful?

Solution

I just did a [[album.view animator] setFrame:newFrame]; and it moved there. Beautiful. (May I add how amazing this is!)

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