Please tell me how to add a ProgressView under the navigation bar? I am trying to use the solution in this post: add a progress bar in the navigation bar , but the code in ObjectiveC was written there ... I'm trying to translate to Swift. This is the code I added to my SubClass NavigationController
import UIKit class CustomNavigationController: UINavigationController { @IBOutlet var Secondprogress: UIProgressView! override func viewDidLoad() { super.viewDidLoad() NSLayoutConstraint.deactivateConstraints(self.view.constraints()) Secondprogress?.setTranslatesAutoresizingMaskIntoConstraints(false) var navBar = self.navigationController?.navigationBar Secondprogress.tag = 1 self.view.addSubview(Secondprogress) var Constraint = NSLayoutConstraint(item: self.Secondprogress, attribute:NSLayoutAttribute.Bottom, relatedBy:NSLayoutRelation.Equal, toItem:navBar, attribute:NSLayoutAttribute.Bottom, multiplier:1.0, constant:-0.5); self.view.addConstraint(Constraint); Constraint = NSLayoutConstraint(item: self.Secondprogress, attribute:NSLayoutAttribute.Left, relatedBy:NSLayoutRelation.Equal, toItem:navBar, attribute:NSLayoutAttribute.Left, multiplier:1.0, constant:0); self.view.addConstraint(Constraint); Constraint = NSLayoutConstraint(item: self.Secondprogress, attribute:NSLayoutAttribute.Right, relatedBy:NSLayoutRelation.Equal, toItem:navBar, attribute:NSLayoutAttribute.Right, multiplier:1.0, constant:0); self.view.addConstraint(Constraint); Secondprogress.setTranslatesAutoresizingMaskIntoConstraints(false) Secondprogress.hidden = false
But when I compile my application, I do not see the ProgressView in the navigation bar.
Where is my mistake?
ios swift uinavigationcontroller uinavigationbar uiprogressview
Dmitry
source share