因此,我正在尝试复制iOS 6 Game Center(适用于iOS 12及更高版本)应用,而我在标签栏和导航栏上苦苦挣扎。
到目前为止,有了代码,我在iPhone Xr上就得到了这样的代码
//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,标签栏也不会一直延伸到底部,而是会重复执行(它将在其他屏幕尺寸上导航栏和/或标签栏弄乱)因此两者的问题仍然存在。为了澄清起见,我希望图像水平重复但垂直向下拉伸。