I actually use this to switch from a ViewController to another
let vue = MAINSTORYBOARD.instantiateViewController(withIdentifier: "addhoraire") as! Addhoraire
self.present(vue, animated: true, completion: nil)
sometimes I want to change something before show the view to user so in the VC with will be present I do a func
. like that
// header and cercle.exemple are outlets of a UIView
public func setup(selectedDay : String){
loadViewIfNeeded()
self.selectedDay = selectedDay
print("jour selectionné : " + self.selectedDay)
self.header.backgroundColor = UIColor.brown
self.profTextField.backgroundColor = UIColor.yellow
self.cercleExemple.backgroundColor = UIColor.yellow
}
And when I want to switch now I do :
let vue = MAINSTORYBOARD.instantiateViewController(withIdentifier: "addhoraire") as! Addhoraire
vue.setup(selectedDay: selectedDayinHoraire)
self.present(vue, animated: true, completion: nil)
So it will switch the new VC and execute setup like I want, ,textfield color is changed, cercleExemple too but header will not. view.backgroundColor
, same problem ... but if I do in the same place header.isHidden = true it work. So it just refuse to change color
header and view bgcolor only change in ViewDidAppear
. I don't understand why. It's been a week since I've been on this bug, it make me crazy ...