我的导航栏中嵌入了一个菜单按钮,它将带我进入菜单。但是,当我点击菜单页面上的“后退”按钮返回到原始主页时,导航栏消失了。
仅在我使用以下代码为两个VC之间的过渡设置动画之后,问题才出现:
菜单按钮的@objc功能:
let transition = CATransition()
transition.duration = 0.5
transition.type = CATransitionType.push
transition.subtype = CATransitionSubtype.fromRight
transition.timingFunction = CAMediaTimingFunction(name:CAMediaTimingFunctionName.easeInEaseOut)
view.window!.layer.add(transition, forKey: kCATransition)
present(menuVC, animated: false, completion: nil)
和@objc函数用于backToHomePage按钮:
let transition = CATransition()
transition.duration = 0.5
transition.type = CATransitionType.push
transition.subtype = CATransitionSubtype.fromLeft
transition.timingFunction = CAMediaTimingFunction(name:CAMediaTimingFunctionName.easeInEaseOut)
view.window!.layer.add(transition, forKey: kCATransition)
present(menuVC, animated: false, completion: nil)
我没有收到任何错误,但是如果我使用导航堆栈将菜单控件推到上方,该问题就消失了。