J'ai écrit le code suivant pour mettre en place la barre de navigation et la vue du contrôleur de vue:UINavigation Bar Couleur
Barre de navigation au AppDelegate:
var navigationController = UINavigationController() navigationController.viewControllers = [mainViewController]
MainViewController A:
self.view.backgroundColor = UIColor.blue let fullScreenRect = UIScreen.main.bounds let buttonSize:CGFloat = 60 let viewLogButton = UIButton(frame: CGRect(x: 0, y: fullScreenRect.size.height-buttonSize, width:fullScreenRect.size.width, height: buttonSize)) viewLogButton.setTitle("View Log", for: UIControlState.normal) viewLogButton.setTitleColor(UIColor.white, for: .normal) viewLogButton.setTitleColor(UIColor.blue, for: .highlighted) viewLogButton.backgroundColor = UIColor.blue viewLogButton.addTarget(self, action: #selector(viewLogButtonPressed), for: .touchUpInside) self.view.addSubview(viewLogButton) self.webView.frame = CGRect(x: 0, y: UIConstants.NAVIGATION_BAR_HEIGHT+UIConstants.STATUS_BAR_HEIGHT, width: fullScreenRect.size.width, height: fullScreenRect.size.height-buttonSize-UIConstants.NAVIGATION_BAR_HEIGHT-UIConstants.STATUS_BAR_HEIGHT) self.view.addSubview(self.webview)
Cela a abouti à une vue avec la barre de navigation supérieure montre une couleur bleue semi-transparente.
je donc la même dans un autre ViewController B (qui est un contrôleur d'affichage de table):
MainViewController B:
let tableView = UITableView() let screenSize: CGRect = UIScreen.main.bounds self.view.backgroundColor = UIColor.blue let screenWidth = screenSize.width let screenHeight = screenSize.height tableView.frame = CGRect(x: 0, y: 0, width: screenWidth, height: screenHeight) self.view.addSubview(tableView)
Je voudrais savoir pourquoi il y a une barre de navigation semi-transparente dans MainVi ewController A mais MainViewController B ne peut pas le montrer?
Comment puis-je faire en sorte que les deux affichent la même barre de navigation semi-transparente?
subClass NavigationController et ajouter des attributs customize .Cette reflétera partout dans l'application. – Ellen