Base Info for this issue
- Version:Latest Version as here
- Language of App :Objective-C
- iOS System Version:iOS12
- Prototype(是否是真机):YES
- Issue Type:Bug、Q-A
1. How to reproduce the problem.
设备:iOS 12,CYL_IS_IPHONE_X为true(刘海屏)
逻辑:自定义页面transition动画,设置from页面需要在to页面推出时进行缩放
现象:CYLTabBar的originY被拉高
原因:在新页面Push出来时,-[CYLTabBarController viewWillLayoutSubviews]被调用,若CYL_IS_IPHONE_X为true则重设self.tabbar的frame。此时获取的self.view.frame.size.height为缩放后的高度尺寸。
这个frame在iOS 12及以上设备都会被错误设置,但在高版本系统中,在-[CYLTabBarController viewWillLayoutSubviews]调用后,系统会再次调用-[UITabBarController _layoutContainerView],这个函数中会重新设置一次tabBar的frame,导致问题在高版本会被修复。-[UITabBarController _layoutContainerView]的这段修复逻辑在iOS 12设备上没有被执行。
2. Please help me in this way.
-[CYLTabBarController viewWillLayoutSubviews]中设置tabBarFrame的逻辑是否能被移除?是否能使用autoLayout方法进行布局?
我翻阅了这段函数前后的日志,发现:
frame.origin.y = self.view.frame.size.height - tabBarHeight;
这行代码在前几年曾被短暂改为:
frame.origin.y = [UIScreen mainScreen].bounds.size.height - tabBarHeight;
后又被改回。这里当初的背景是?
3. Here is a Demo.
- (void)openAnimation:(id <UIViewControllerContextTransitioning>)transitionContext{
UIModalPresentationStyle style = [transitionContext presentationStyle];
UIView *container = [transitionContext containerView];
UIView *fromView = [transitionContext viewForKey:UITransitionContextFromViewKey];
UIView *toView = [transitionContext viewForKey:UITransitionContextToViewKey];
[container addSubview:fromView];
self.bgView.frame = container.bounds;
self.bgView.alpha = 0;
[container addSubview:self.bgView];
[container addSubview:toView];
NSTimeInterval duration = 0.5f;
fromView.userInteractionEnabled = NO;
toView.userInteractionEnabled = NO;
container.backgroundColor = UIColor.clearColor;
void(^finishBlock)(void) = ^{
[transitionContext completeTransition:!transitionContext.transitionWasCancelled];
fromView.transform = CGAffineTransformIdentity;
toView.transform = CGAffineTransformIdentity;
toView.userInteractionEnabled = YES;
fromView.userInteractionEnabled = YES;
fromView.alpha = 1;
toView.alpha = 1;
container.backgroundColor = UIColor.clearColor;
};
container.backgroundColor = UIColor.blackColor;
toView.transform = CGAffineTransformMakeTranslation(toView.frame.size.width, 0);
[UIView animateWithDuration:duration delay:0 usingSpringWithDamping:1 initialSpringVelocity:0 options:UIViewAnimationOptionCurveLinear animations:^{
fromView.transform = CGAffineTransformMakeScale(self.scale, self.scale);
toView.transform = CGAffineTransformIdentity;
self.bgView.alpha = 1;
} completion:^(BOOL finished) {
finishBlock();
}];
}
4. Here is my Debug log

Base Info for this issue
1. How to reproduce the problem.
设备:iOS 12,CYL_IS_IPHONE_X为true(刘海屏)
逻辑:自定义页面transition动画,设置from页面需要在to页面推出时进行缩放
现象:CYLTabBar的originY被拉高
原因:在新页面Push出来时,-[CYLTabBarController viewWillLayoutSubviews]被调用,若CYL_IS_IPHONE_X为true则重设self.tabbar的frame。此时获取的self.view.frame.size.height为缩放后的高度尺寸。
这个frame在iOS 12及以上设备都会被错误设置,但在高版本系统中,在-[CYLTabBarController viewWillLayoutSubviews]调用后,系统会再次调用-[UITabBarController _layoutContainerView],这个函数中会重新设置一次tabBar的frame,导致问题在高版本会被修复。-[UITabBarController _layoutContainerView]的这段修复逻辑在iOS 12设备上没有被执行。
2. Please help me in this way.
-[CYLTabBarController viewWillLayoutSubviews]中设置tabBarFrame的逻辑是否能被移除?是否能使用autoLayout方法进行布局?
我翻阅了这段函数前后的日志,发现:
frame.origin.y = self.view.frame.size.height - tabBarHeight;
这行代码在前几年曾被短暂改为:
frame.origin.y = [UIScreen mainScreen].bounds.size.height - tabBarHeight;
后又被改回。这里当初的背景是?
3. Here is a Demo.
4. Here is my Debug log