从大标题页过渡到小标题页时出现导航间隙 [英] Navigation gap appears When transition from Large title Page to small Title Page

查看:30
本文介绍了从大标题页过渡到小标题页时出现导航间隙的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从大标题页滑动到小标题页时出现导航间隙!

Navigation gap appears when swipe from large title page to small title page!

推荐答案

视图的布局从导航栏的底部开始.从大标题页过渡到小标题页时,导航栏变短,出现导航间隙.

The view's layout starts from the bottom of the navigation bar. When transit from large title page to small title page, the navigation bar becomes shorter, then the navigation gap appears.

为了解决这个问题,控制器视图的布局应该从屏幕的零点开始,子视图的布局应该从导航栏的底部开始,以防止被覆盖.

To resolve this problem, the layout of the controller's view should start from the zero point of the screen, and it's subviews' layout should start from the bottom of the navigation bar to prevent from being covered.

两个属性可以影响布局:translucentedgesForExtendedLayout.半透明属性应该设置为YES,或者到处删除它(默认值为YES).edgeForExtendedLayout 属性应该设置为 UIRectEdgeAll,或者删除它(默认值是 UIRectEdgeAll).

Two properties can effect the layout: translucent and edgesForExtendedLayout. The translucent property should be set to YES, or delete it everywhere(It's default value is YES). The edgesForExtendedLayout property should be set to UIRectEdgeAll, or delete it everywhere(It's default value is UIRectEdgeAll).

对于UITableViewController的页面,会自动调整到navigationbar(tableview的adjustedContentInset会发生变化,前提是设置contentInsetAdjustmentBehaviorUIScrollViewContentInsetAdjustmentAutomatic,或者删除设置),任何其他代码都不应更改.

For UITableViewController's page, it will automatically adjust to the navigationbar(tableview's adjustedContentInset will change, the premise is set contentInsetAdjustmentBehavior to UIScrollViewContentInsetAdjustmentAutomatic, or delete the setting), any other code should not change.

对于 UIViewController,主视图的子视图应该将其布局调整到导航栏的底部.示例代码如,

For UIViewController, the subviews' of the main view should adjust its layout to the bottom of the navigation bar. The example code like,

- (void)viewDidLayoutSubviews
{
    [super viewDidLayoutSubviews];
    self.searchBgTopLayoutConstraint.constant = NORMAL_STATUS_AND_NAV_BAR_HEIGHT;
    #top constraint of the top most view
}

如果子视图的第一个视图(A)继承自UIScrollView,大标题会随着A的滚动而变化.详细信息可以在 滚动时缩小大标题(不是 UITableViewController) iOS 11.

If the first view (A) of the subviews inherits from UIScrollView, and the large title will change according to the A's scroll. The detail can be found in Shrink large title when scrolling (not UITableViewController) iOS 11 .

如果最上面的view继承自UIScrollView,比如mainTableView,你可以设置它的布局从零点开始,设置它的contentInset到导航的底部酒吧.它看起来像一个 UITableViewController,导航栏在 mainsTableView 滚动时发生变化,没有任何空白.示例代码如,

If the top most view inherites from UIScrollView, like mainTableView, you can set its layout start from the zero point, and set its contentInset to the bottom of the navigation bar. It looks like an UITableViewController, and the navigation bar changes when mainsTableView scrolling, without any white space. The example code like,

- (void)viewDidLayoutSubviews
{
    [super viewDidLayoutSubviews];
    self.mainTableView.contentInset = UIEdgeInsetsMake(NORMAL_STATUS_AND_NAV_BAR_HEIGHT, 0, 0, 0);
}

这篇关于从大标题页过渡到小标题页时出现导航间隙的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆