How to flip and animate growth like in iPhoto 09?

I am developing a Cocoa application and want me to be able to click on a button in one of the views in my NSCollectionView and open the details view and put it in the middle of the screen, like in iPhoto 09 when you click β€œi” in the lower right corner of the photo. The photo flips and grows in the center of the window to show details about the photo.

I guess they use Core Animation to achieve this. I watched the Lemur Flip example, but when I try to modify it to add repositioning of the code to the animation, it resets the flip.

Here is the positioning code that I added to the sender - (IBAction) flip: (id); LemurFlip Code:

...
[CATransaction begin]; {
NSSize supersize = contentView.frame.size; // Size of window content view
NSSize subsize = frontView.frame.size; // Size of view we're flipping out
if(!frontView.isHidden)
{
    // Move views to middle of the window
    [[backView animator] setFrameOrigin:NSMakePoint((supersize.width / 2) - (subsize.width / 2), (supersize.height / 2) - (subsize.height / 2))];
    [[frontView animator] setFrameOrigin:NSMakePoint((supersize.width / 2) - (subsize.width / 2), (supersize.height / 2) - (subsize.height / 2))];
}
else {
    // Return views to point of origin
    [[backView animator] setFrameOrigin:NSMakePoint(0, 0)];
    [[frontView animator] setFrameOrigin:NSMakePoint(0, 0)];
}
    [hiddenLayer addAnimation:[self _flipAnimationWithDuration:flipDuration isFront:NO] forKey:@"flipGroup"];
    [visibleLayer addAnimation:[self _flipAnimationWithDuration:flipDuration isFront:YES] forKey:@"flipGroup"];
} [CATransaction commit];
...

, - ?

+3
1

[[backView animator] setFrameOrigin:];
[[frontView animator] setFrameOrigin:];

[hiddenLayer setPosition:];
[visibleLayer setPosition:];

, , CABasicAnimation

+1

Source: https://habr.com/ru/post/1745679/


All Articles