frdnrdb
frdnrdb

Reputation: 61

NSAnimationContext misbehaving

I have a button that triggers the main window to animate it's height thus displaying some options in a pull-down-menu. The button (and it's sibling) are placed in the two bottom corners of the window, so i want them to animate down with the window - being "locked" in a fixed distance from the bottom window edge.

Problem: The buttons animate properly maybe 1 out of 10 times - the rest of the time they get offset seemingly randomly on the y-axis. On top of that the two buttons get different offsets - they don't behave identical, although the animation code is the same.

Deployed and run on OSX 10.9 Mavericks the animation works properly - no misbehaving there.

Any ideas on how to get the following, simple code to work on OSX < 10.9?

    [NSAnimationContext beginGrouping];
    [[NSAnimationContext currentContext] setDuration:0.2f];
    [[[self window] animator] setFrame:NSMakeRect([self window].frame.origin.x, [self window].frame.origin.y-EXTRA_HEIGHT, ORIGINAL_WIDTH, ORIGINAL_HEIGHT+EXTRA_HEIGHT) display:YES];
    [[_buttonOne animator] setFrameOrigin:NSMakePoint([_buttonOne frame].origin.x, CONSTANT_NUMBER)];
    [[_buttonTwo animator] setFrameOrigin:NSMakePoint([_buttonTwo frame].origin.x, CONSTANT_NUMBER)];
    [NSAnimationContext endGrouping];

Upvotes: 1

Views: 196

Answers (0)

Related Questions