我试图创建一个透明的模态弹出式动画,我开始工作,除非我旋转视图时,它保持相同的大小。有人能指出我正确的方向吗?以下是我目前使用的动画代码
- (void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext {
UIView *inView = [transitionContext containerView];
UIViewController *toVC = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
UIViewController *fromVC = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
[inView addSubview:toVC.view];
CGRect screenRect = fromVC.view.bounds;
[toVC.view setFrame:CGRectMake(0, screenRect.size.height, fromVC.view.frame.size.width, fromVC.view.frame.size.height)];
[UIView animateWithDuration:0.25f
animations:^{
[toVC.view setFrame:CGRectMake(0, 0, fromVC.view.frame.size.width, fromVC.view.frame.size.height)];
}
completion:^(BOOL finished) {
[transitionContext completeTransition:YES];
}];
}
答案 0 :(得分:0)
我只是尝试使用组合自动布局的代码,视图调整大小适合我。只是为了确保,这是你想要实现的目标吗?
修改强> 以下是我实施此步骤的步骤
在父视图控制器中实现animationControllerForPresentedController方法,如此
-(id<UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController:(UIViewController *)presented presentingController:(UIViewController *)presenting sourceController:(UIViewController *)source{
return [[MyTransitionClass alloc] init];
}