Как правильно придать панели навигации и панели вкладок фоновое изображение? - PullRequest
1 голос
/ 17 июня 2019

Итак, я пытаюсь скопировать приложение iOS 6 Game Center (для iOS 12 и выше) прямо сейчас, и я борюсь с панелью вкладок и панелью навигации.

С кодом, который у меня есть, он выглядит так на iPhone Xr enter image description here

//This puts the iOS 6 Game Center image in a UIImage.
let navigationAndTabBarImage = UIImage(named: "GameCenterNavigationAndTabBarStyle")!
//This sets the content mode to scale to fill which is supposed to stretch out the image to fit.
UITabBar.appearance().contentMode = UIView.ContentMode.scaleToFill
        self.tabBarController?.tabBar.contentMode = UIView.ContentMode.scaleToFill
//This changes the tab bar's background image to navigationAndTabBarImage.
        self.tabBarController?.tabBar.backgroundImage = navigationAndTabBarImage
//This sets the content mode to scale to fill which is supposed to stretch out the image to fit.
UINavigationBar.appearance().contentMode = UIView.ContentMode.scaleToFill
        self.navigationController?.navigationBar.contentMode = UIView.ContentMode.scaleToFill
//This changes the navigation bar's background image to navigationAndTabBarImage.
       self.navigationController?.navigationBar.setBackgroundImage(navigationAndTabBarImage, for: .default)

но, как вы видите, панель вкладок не просто растягивается, а повторяется, даже если я установил режим содержимого ScaleToFill, чтобы он растягивался (а на экранах других размеров панель навигации и / или панель вкладок портятся) так что проблема сохраняется с обоими). Чтобы уточнить, я бы хотел, чтобы изображение повторялось по горизонтали, но растягивалось вертикально.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...