简体   繁体   English

向后搜索后导航栏重叠图像

[英]Navigation bar overlapping image after back segue

在此处输入图片说明

Navigation bar overlaps the image after user back from segue. 用户从segue返回后,导航栏会与图像重叠。

When the view first loaded it looks ok but after performing the segue and come back it looks like this. 首次加载视图时,它看起来还不错,但是在执行了segue然后返回后,它看起来像这样。

here is the code for that image 这是该图像的代码

let logoContainer = UIView(frame: CGRect(x: 0, y: 0, width: 200, height: 67))
        let imageView = UIImageView(frame: CGRect(x: 0, y: -30, width: 200, height: 67))
        imageView.contentMode = .scaleAspectFit
        let image = UIImage(named: "navbarlogo")
        imageView.image = image
        logoContainer.addSubview(imageView)
        navigationItem.titleView = logoContainer

Honestly, your problem is the fact you are creating an overlap of the ImageView by specifying a -30 y coordinate. 老实说,您的问题是您通过指定-30 y坐标创建了ImageView的重叠部分。 It's higher in the z-order (compared to your navigation bar) in one case but lower in the z-order in the segue scenario. 在一种情况下,z顺序较高(与导航栏相比),但在segue场景中,z顺序较低。

I suspect if you use "Debug View Hierarchy" in XCode in both scenarios, you would be able to see this is what is happening. 我怀疑如果在两种情况下都在XCode中使用“调试视图层次结构”,您将能够看到正在发生的事情。

I would change your approach as to how the logo container is being laid out 我会改变您的徽标容器布局方式

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM