I would like to present a modal View Controller with a custom Segue including UIKit Dynamics.
Copied the following code by rdelmar in this post https://stackoverflow.com/a/23039173/1016102 and tried to modify it for what i want.
-(id)initWithIdentifier:(NSString *)identifier source:(UIViewController *)source destination:(UIViewController *)destination {
if (self = [super initWithIdentifier:identifier source:source destination:destination]) {
UIViewController *src = self.sourceViewController;
UIViewController *dest = self.destinationViewController;
self.animator = [[UIDynamicAnimator alloc] initWithReferenceView:src.view];
[src addChildViewController:dest];
[dest didMoveToParentViewController:src];
dest.view.frame = CGRectMake(0, 300, src.view.bounds.size.width, src.view.bounds.size.height);
[src.view addSubview:dest.view];
}
return self;
}
-(void)perform {
UIGravityBehavior* gravityBehavior = [[UIGravityBehavior alloc] initWithItems:@[[self.destinationViewController view]]];
CGVector vector = CGVectorMake(0, -1);
[gravityBehavior setGravityDirection:vector];
UICollisionBehavior *collide = [[UICollisionBehavior alloc] initWithItems:@[[self.destinationViewController view]]];
CGPoint left = CGPointMake(self.animator.referenceView.bounds.origin.x, self.animator.referenceView.bounds.origin.y + self.animator.referenceView.bounds.size.height);
CGPoint right = CGPointMake(self.animator.referenceView.bounds.origin.x + self.animator.referenceView.bounds.size.width, self.animator.referenceView.bounds.origin.y + self.animator.referenceView.bounds.size.height);
[collide addBoundaryWithIdentifier:@"top" fromPoint:left toPoint:right];
[collide setCollisionDelegate:self.sourceViewController];
[self.animator addBehavior:gravityBehavior];
[self.animator addBehavior:collide];
}
Sadly my destination Controller appears on the wrong position and is disapperaing directly after the collision.
I would like to achive some result as in the following sketch.
Actually my UI is acting like this: I tap the "+" button which fires my custom-segue and the the black box pops directly under the orange NavigationBar. it doesn't pop from the bottom border of the orange box like in the sketch. it just appears and disappers with popping over the top.
What should i edit to achive this?