【发布时间】:2020-08-07 21:51:29
【问题描述】:
我有一个带有“关闭”按钮的视图控制器,它位于导航栏的位置。 看起来是这样的:
我隐藏导航栏的代码:
self.navigationController!.navigationBar.setBackgroundImage(UIImage(), for: .default)
self.navigationController!.navigationBar.shadowImage = UIImage()
self.navigationController!.navigationBar.isTranslucent = true
navItem.setHidesBackButton(true, animated: true)
按钮可见,但修饰事件不起作用。如果我将按钮移动到导航栏区域下方,一切正常。
我试过了:
self.navigationController!.navigationBar.isUserInteractionEnabled = true
self.navigationController!.navigationBar.isExclusiveTouch = false
不幸的是,它没有帮助。我该如何解决这个问题?
【问题讨论】:
-
您的代码应该可以工作,但如果您遇到按钮调用问题,那么肯定是其他地方存在问题,您能否在这里分享您的代码 zip,以便我可以帮助您
-
嗨,它是这样工作还是完全不工作? stackoverflow.com/questions/61278358/…
-
您是否有理由不隐藏导航栏?
self.navigationController?.setNavigationBarHidden(true, animated: false)
标签: ios swift uibutton autolayout uinavigationbar