My problem is really simple, I don't know how to display a list (menu) below the Navigation bar, when I click on it (on the Navigation Bar).
I would like to do the same thing than this image:
I tried to do this:
func doSomething(){
let navigationBarHeight = self.navigationController?.navigationBar.frame.height ?? 0
print(navigationBarHeight)
let heightTotal = UIApplication.shared.statusBarFrame.height + navigationBarHeight
DispatchQueue.main.async(execute: {
appDelegate.infoView(message: "test", Yorigin: heightTotal, color: colorBlueFollow)
})
}
And this in appDelegate:
func infoView(message: String, Yorigin: CGFloat ,color: UIColor){
if infoViewIsShowing == false{
infoViewIsShowing = true
// let infoViewHeight = self.window!.bounds.height / 14.2
let infoViewHeight = self.window!.bounds.height / 4.2
let infoViewY = Yorigin - infoViewHeight
let infoView = UIView(frame: CGRect(x: 0, y: infoViewY, width: self.window!.bounds.width, height: infoViewHeight))
infoView.backgroundColor = color
self.window!.addSubview(infoView)
let infoLabelWidth = infoView.bounds.width
let infoLabelHeight = infoView.bounds.height + UIApplication.shared.statusBarFrame.height/2
let infoLabel = UILabel()
infoLabel.frame.size.width = infoLabelWidth
infoLabel.frame.size.height = infoLabelHeight
infoLabel.numberOfLines = 0
infoLabel.text = message
infoLabel.font = UIFont(name: "HelveticaNeue", size: 11)
infoLabel.textColor = UIColor.white
infoLabel.textAlignment = .center
infoView.addSubview(infoLabel)
// Animate errorView
UIView.animate(withDuration: 0.2, animations: {
// Move down
infoView.frame.origin.y = Yorigin
}, completion: { (finished: Bool) in
if finished{
UIView.animate(withDuration: 0.2, delay: 3, options: .curveLinear, animations: {
// move up
infoView.frame.origin.y = infoViewY
}, completion: { (finished: Bool) in
if finished {
infoView.removeFromSuperview()
infoLabel.removeFromSuperview()
self.infoViewIsShowing = false
}
})
}
})
}
}
The problem is that, the view shown is passing above the Navigation Bar, it's not the effect that I would like. Do you have an idea about how I can do that?