Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/108.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 导航栏图像上的方面填充?_Ios_Swift_Uiimage_Uinavigationbar - Fatal编程技术网

Ios 导航栏图像上的方面填充?

Ios 导航栏图像上的方面填充?,ios,swift,uiimage,uinavigationbar,Ios,Swift,Uiimage,Uinavigationbar,我想为我的导航控制器的背景图像实现与imageView方面填充相同的外观 目前,我正在使用此设置图像: UINavigationBar.appearance().setBackgroundImage(imageToCache?.resizableImage(withCapInsets: UIEdgeInsetsMake(0, 0, 0, 0), resizingMode: UIImageResizingMode.stretch), for: .default) UIImageResizingM

我想为我的导航控制器的背景图像实现与imageView方面填充相同的外观

目前,我正在使用此设置图像:

UINavigationBar.appearance().setBackgroundImage(imageToCache?.resizableImage(withCapInsets: UIEdgeInsetsMake(0, 0, 0, 0), resizingMode: UIImageResizingMode.stretch), for: .default)
UIImageResizingMode.stretch显然让我看起来很不舒服。我不在乎图像是否在顶部/底部被切断,我只需要将其放入导航栏中,显示全尺寸和显示的内容

我不能将零传递到调整大小模式

还有

init(rawValue:)) 
用于调整大小模式的选项,但我在其中输入的任何数字都会导致背景中不再有图像

有什么想法吗

编辑:


以上结果不会显示任何图片。

请尝试使用此选项。希望你能工作

UINavigationBar.appearance().setBackgroundImage(imageToCache‌​, forBarMetrics: .Default)

设置contentMode=。ScaleAspectFit@NazmulHasan我添加了一个编辑,如果你能看的话。你知道为什么没有图片显示吗?@NazmulHasan是的,我正在运行if/else,如果没有的话可以下载。当我使用UINavigationBar.appearance()代码时,该代码用于下载/缓存,但尝试使用视图却不起作用。UINavigationBar.appearance().setBackgroundImage(imageToCache,forBarMetrics:.Default)是的。非常感谢你。我不知道为什么我要使用可调整大小的lol。
UINavigationBar.appearance().setBackgroundImage(imageToCache‌​, forBarMetrics: .Default)