gpt4 book ai didi

ios - UI导航标题查看错误

转载 作者:行者123 更新时间:2023-11-30 13:03:58 25 4
gpt4 key购买 nike

如果我为导航标题 View 设置搜索栏,例如

navigationController?.navigationBar.topItem?.titleView = self.searchBar

,但我使用自动布局设置它的框架,例如:

self.searchBar.snp_makeConstraints { make in
make.left.equalTo(leftSpace)
make.right.equalTo(-leftSpace)
make.top.equalTo(10)
make.height.equalTo(44)
}

,然后如果我推送到另一个 View Controller ,就会导致损坏。

如果我使用这种方式设置它的框架:

self.searchBar.frame = CGRectMake(leftSpace, 0, screenSize.width - 2 * leftSpace, 44)

运行良好...

谁能告诉我为什么?谢谢...

最佳答案

TitleView 的布局由导航 Controller 管理。添加到 View 的约束在添加到 titleView 时将被忽略。如果您想完全自定义导航栏,我建议您创建自己的 View 。

关于ios - UI导航标题查看错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39609160/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com