In my main UIViewController
embed in UINavigationController
I have add an UILabel to a navigationBar using that code:
if let navigationBar = self.navigationController?.navigationBar {
let frameDomanda = CGRect(x: navigationBar.frame.width/2 - domandaN.frame.width/2, y: -10, width: domandaN.frame.width, height: navigationBar.frame.height)
domandaN.frame = frameDomanda
let secondLabel = UILabel(frame: secondFrame)
secondLabel.text = "Second"
navigationBar.addSubview(domandaN)
}
But when I change Controller the UILabel is fixed. It doesn't disappear so I've added that code:
override func viewDidDisappear(animated: Bool) {
domandaN.removeFromSuperview()
}
It works but I want it to disappear immediately after the press of the back button. Not like this image: (The "example" text goes away later)