I have a custom view containing an UIButton that I want to use as titleView:
let titleView = Bundle.main.loadNibNamed("TitleView", owner: self,
options: nil)?[0] as? TitleView
titleView?.title.text = self.title
navigationController?.navigationBar.topItem?.titleView = titleView
The button is linked with an IBAction in it's class. The View is displayed correctly in the navigation bar, but the button is not working. It doesn't even get highlighted during the touch. Looks like something is preventing the touch event.
CodePudding user response:
Add the code below to your titleView
override var intrinsicContentSize: CGSize {
return UIView.layoutFittingExpandedSize
}