简体   繁体   English

iOS 11-将背景图像添加到导航栏

[英]iOS 11 - Adding Background image to Navigation bar

I have a view controller with Large Titles and I want to add a background image to it so it takes up the whole navigation bar. 我有一个带有大标题的视图控制器,我想向其添加背景图像,以使其占据整个导航栏。 Does anyone know the best way to do this. 有谁知道最好的方法做到这一点。 I've search all over the internet but yet to find any good examples. 我已经在整个互联网上进行搜索,但没有找到任何好的示例。 Thank you 谢谢

Goal is to look like this view from starbucks app. 目标是看起来像来自星巴克应用程序的此视图。

单击此查看我想要它的外观的示例

I have checked the image. 我检查了图像。 I think the best way is to add an image view at top. 我认为最好的方法是在顶部添加图像视图。 Then on that image view place two buttons with appropriate constraints. 然后在该图像视图上放置两个具有适当约束的按钮。 Then underneath that image view, add the tableview. 然后在该图像视图下添加tableview。 Then in the table view cell, at first index you can add the textview, if it is a large text and underneath cells will cover all the things your require with labels in the left and the > image in the right which will lead to a different screen. 然后,在表格视图单元格中,第一个索引可以添加textview,如果它是大文本,则其下方的单元格将覆盖您所需的所有内容,左侧标签,右侧>图像,这将导致不同的内容屏幕。

I ran into a similar problem just like this and I didn't find any solution over the internet neither. 就像这样,我遇到了类似的问题,而且我也没有在互联网上找到任何解决方案。 But I do have a simple work around that might be helpful. 但是我确实有一项简单的工作可能会有所帮助。

What I did is setting the image as navigation bar's background and also add the image to the view in the VC. 我要做的是将图像设置为导航栏的背景,并将图像添加到VC中的视图中。 Make sure the navigation bar has no shadow and its translucent property is set to NO . 确保导航栏没有阴影,并且其translucent属性设置为NO

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

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