我有一个问题(与Objective-C相关)。
我想通过单击注释在根映射视图控制器顶部创建从底部ViewController滑动。
1)点击注释后,它应从底部滑动并显示10%的高度;
2)向上滑动手势后 - 如果用户将其完全向上拖动,它应显示高达100%;
3)在向下手势上,用户应该能够将其可见高度再次降低到10%;
4)在MapView上单击底部的ViewController应该隐藏。
我包括流程实施的可视化方案。
非常感谢任何想法!
答案 0 :(得分:1)
答案 1 :(得分:0)
您始终可以尝试编写自己的segue动画以在ViewControllers之间进行切换。只需创建一个自定义的UIStoryboardSegue,并覆盖其perform方法。以下是一段摘录:
@interface HorizontalSegue : UIStoryboardSegue
@property CGPoint originatingPoint;
@end
@implementation VerticalSegue
- (void)perform {
UIViewController *sourceViewController = self.sourceViewController;
UIViewController *destinationViewController = self.destinationViewController;
NSArray* windowArray = [UIApplication sharedApplication].windows;
if (windowArray.count > 0) {
UIWindow* appWindow = [windowArray lastObject];
[appWindow insertSubview:destinationViewController.view aboveSubview:sourceViewController.view];
}
else
[sourceViewController.view addSubview:destinationViewController.view];
// Store original centre point of the destination view
CGPoint originalCenter = destinationViewController.view.center;
// Set center to start point of the button
destinationViewController.view.center = CGPointMake(self.originatingPoint.x, self.originatingPoint.y*3);
[UIView animateWithDuration:0.25
delay:0.0
options:UIViewAnimationOptionCurveEaseInOut
animations:^{
destinationViewController.view.center = originalCenter;
}
completion:^(BOOL finished){
[sourceViewController presentViewController:destinationViewController animated:NO completion:NULL]; // present VC
}];
}
@end
使用此功能,您可以轻松制作自定义动画。我不完全确定将ViewController添加到窗口的部分是否正确,但您可以尝试自行检查/纠正。
动画segues的另一种方法是使用CATransition:
-(void)perform
{
UIViewController *sourceViewController = (UIViewController*)[self sourceViewController];
UIViewController *destinationController = (UIViewController*)[self destinationViewController];
CATransition* transition = [CATransition animation];
transition.duration = 0.25;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionMoveIn; //kCATransitionMoveIn; //, kCATransitionPush, kCATransitionReveal, kCATransitionFade
transition.subtype = kCATransitionFromLeft; //kCATransitionFromLeft, kCATransitionFromRight, kCATransitionFromTop, kCATransitionFromBottom
[destinationController.view.layer addAnimation:transition forKey:kCATransition];
[sourceViewController presentViewController:destinationController animated:NO completion:nil];
}