【发布时间】:2019-10-27 15:34:32
【问题描述】:
我有一个UIViewController,它使用自定义过渡呈现,按照设计,它只填充屏幕高度的 90%。
这看起来不错,我从来没有遇到过任何问题。我们称之为视图 A。现在我试图在此之上呈现一个全屏模式视图,我们称之为视图 B。这种外观有效,但是当视图 B 被关闭时,视图 A 重新出现,但已扩展以填充整个屏幕边界。
这是我正在使用的演示代码:
- (void)animateTransition:(id <UIViewControllerContextTransitioning>)transitionContext
{
...
// Presentation
const CGFloat viewHeight = (screenBounds.size.height * 0.9);
const CGRect beginFrame = CGRectMake(0, screenBounds.size.height, screenBounds.size.width, viewHeight);
const CGRect finalFrame = CGRectMake(0, (screenBounds.size.height - viewHeight), screenBounds.size.width, viewHeight);
// Dim
self.dimmedView.alpha = 0.0;
[transitionContext.containerView addSubview:self.dimmedView];
[transitionContext.containerView addConstraints:[NSLayoutConstraint allConstraintsFromViewToSuperview:self.dimmedView inset:UIOffsetZero]];
// Prepare
UIView * const toView = toVC.view;
toView.frame = beginFrame;
[transitionContext.containerView addSubview:toView];
// Animate
[UIView animateWithDuration:kAnimationDuration delay:0.0 usingSpringWithDamping:0.8 initialSpringVelocity:0.25 options:0 animations:^{
toView.frame = finalFrame;
self.dimmedView.alpha = 0.6;
self.tabBarController.view.layer.cornerRadius = 8.0;
self.tabBarController.view.transform = CGAffineTransformMakeScale(0.95, 0.95);
} completion:^(BOOL finished) {
[transitionContext completeTransition:!transitionContext.transitionWasCancelled];
[offshootView removeFromSuperview];
}];
...
}
有没有人见过这个,并且知道如何阻止系统调整视图 A 的大小?
【问题讨论】:
标签: ios objective-c uiviewcontroller