I used tabBarItem & UITabBarController create a demo app. then I set every pages backgroudcolor as red. when I change to every pages withing the tabBarItem at bottom. the page's background color highlight every time. I don't know why. Is this the new UIKit's bug?
show bugs in iOS 18
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
guard let scene = (scene as? UIWindowScene) else { return }
let a = UINavigationController(rootViewController: AViewController())
let b = UINavigationController(rootViewController: BViewController())
let c = UINavigationController(rootViewController: CiewController())
a.tabBarItem = UITabBarItem(title: "AAA", image: nil, selectedImage: nil)
b.tabBarItem = UITabBarItem(title: "BBB", image: nil, selectedImage: nil)
c.tabBarItem = UITabBarItem(title: "CCC", image: nil, selectedImage: nil)
let tabbarVc = UITabBarController()
tabbarVc.viewControllers = [a,b,c]
window?.backgroundColor = .clear
window?.rootViewController = tabbarVc
window?.makeKeyAndVisible()
}
import UIKit
class AViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
self.view.backgroundColor = .red
// Do any additional setup after loading the view.
}
}