是否可以将UIView的顶部固定在导航栏的底部? [英] Is it possible to pin a UIView's top to the bottom of the navigation bar?

查看:146
本文介绍了是否可以将UIView的顶部固定在导航栏的底部?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将我的UIView定位在导航栏下为20pt,但是当我将其相对于视图控制器上的视图设置时,它仍位于导航栏下为20pt,并且我不想对其进行硬编码

I'm trying to position my UIView to be 20pt under the navigation bar, but when I set it relative to the view on the view controller it's still under the navigation bar at 20pt, and I don't want to hardcode it.

是否可以将其放置在导航栏之外?

Is it possible to position it away from the navigation bar?

推荐答案

尝试使用TopLayoutGuide添加约束,

Try adding contraint with TopLayoutGuide,

TopLayoutGuide与self.view之间的主要区别在于,顶部布局指南以bottom of status bar + bottom of navigation bar(if exist)开头,但self.view始终从iOS 7中的半透明导航栏的(0,0)坐标开始.

The main difference between TopLayoutGuide and self.view is, top layout guide starts with bottom of status bar + bottom of navigation bar(if exist), but self.view always start from (0,0) coordinate in iOS 7 for translucent navigation bar.

因此,在您的情况下,您应该尝试从顶部布局指南中进行固定.

So in your case you should try pinning from top layout guide.

这篇关于是否可以将UIView的顶部固定在导航栏的底部?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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