适用于iOS 10 XCode 8.1 Swift 3.0的NavigationBar背景图片 [英] NavigationBar background image for iOS 10 XCode 8.1 Swift 3.0

查看:76
本文介绍了适用于iOS 10 XCode 8.1 Swift 3.0的NavigationBar背景图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何为此特定设置设置背景图像? iOS10 XCode8.1
我尝试了以下所有内容:

How to set the background image for this specific settings? iOS10 and XCode8.1? I tried everything below:

UINavigationBar.appearance().setBackgroundImage(UIImage(named: "navigationBg")!.resizableImage(withCapInsets: UIEdgeInsetsMake(0, 0, 0, 0), resizingMode: .stretch), for: .default)
UINavigationBar.appearance().setBackgroundImage(UIImage(named: "navigationBg")! , for: .any, barMetrics: .default)
UINavigationBar.appearance().setBackgroundImage(UIImage(named: "navigationBg")! , for: .default)

我可以使用 storyboard navigationBar 的颜色$ c>但无法设置图像。

I'm able to set the color of navigationBar using storyboard but unable to set the image.

推荐答案

尝试设置self.navigationItem.titleView属性

Trying setting "self.navigationItem.titleView" property

参考:如何将图像作为导航栏标题

更新:

试试这个,而不是在UIN中设置avigationBar()

Try this, instead of setting in UINavigationBar()

let navBackgroundImage:UIImage! = UIImage(named: "<navigationBarImage>")
self.navigationController?.navigationBar.setBackgroundImage(navBackgroundImage,
                                                            for: .default)

这篇关于适用于iOS 10 XCode 8.1 Swift 3.0的NavigationBar背景图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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