现象
未命名.2019-08-01 11_51_50.gif
Push Storyboard按钮事件Push到最后一个页面。
Back Button先从Tab Bar(此时已经隐藏了)的顶部,然后回到底部。
用为代码描述,大概是经历了
back.bottomConstraint.constant = -tabbarHeight;
back.bottomConstraint.constant = 0.0f;
环境
iOS 10.3.3-
Storyboard布局 - 视图层级
屏幕快照 2019-07-31 下午7.24.41.png
- 最后一页,
BackButton布局
屏幕快照 2019-07-31 下午7.26.51.png
Hide Bottom Bar on Push: YES
原因
Safe Area是iOS 11的特性,对iOS 10支持得不太好(< iOS 11估计都有问题),需要做适配。
但奇怪的是,我还没发现Safe Area Top需要适配,显然Safe Area Bottom需要。
解决办法
屏幕快照 2019-07-31 下午7.49.24.png
然后绑定约束为属性,代码适配,代码像这样
@interface YourViewController ()
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *bottomConstraint;
@end
@implementation YourViewController
- (void)viewDidLoad {
[super viewDidLoad];
CGFloat bottomValue = 0.0f; // your value
UIEdgeInsets edgeInsets = UIApplication.sharedApplication.keyWindow.layoutMargins;
CGFloat bottomInset = edgeInsets.bottom;
self.bottomConstraint.constant = - bottomInset - bottomValue;
}
@end
为什么
为啥不用直接Storyboard适配,因为Storyboard没办法搞这种适配,可能是我没找到,有的话告诉我❤️










网友评论