Skip to content

Instantly share code, notes, and snippets.

@McZonk
Forked from michaelochs/IrisSegue.mm
Created May 23, 2013 07:35
Show Gist options
  • Save McZonk/5633310 to your computer and use it in GitHub Desktop.
Save McZonk/5633310 to your computer and use it in GitHub Desktop.
@implementation IrisSegue
- (void)perform
{
CATransition *shutterAnimation = [CATransition animation];
[shutterAnimation setDelegate:self];
[shutterAnimation setDuration:0.5];
shutterAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
[shutterAnimation setType:@"cameraIris"];
[shutterAnimation setStartProgress:0.5];
CALayer *cameraShutter = [[CALayer alloc]init];
[cameraShutter setBounds:CGRectMake(0.0, 0.0, 320.0, 425.0)];
UIViewController* destination = self.destinationViewController;
[self.sourceViewController presentViewController:self.destinationViewController animated:NO completion:^{
// don't ask - it just works with two calls to dispatch_async
dispatch_async(dispatch_get_main_queue(), ^{
dispatch_async(dispatch_get_main_queue(), ^{
[destination.view.layer addSublayer:cameraShutter];
[destination.view.layer addAnimation:shutterAnimation forKey:@"cameraIris"];
});
});
}];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment