I'm trying to use a customView as rightBarButtonItem using the UIBarButtonItem(customView: UIView)
initializer. My customView is basically a stackView with two objects: an imageView and a label. I added a tapgesturerecognizer to the whole view. Using this view outside of the UIBarButtonItem (like a toast or similar) is not a problem. It seems that the event is intercepted by the button and not forwarded to it's customView.
Adding tapgesturerecognizer to customView (e.g. cloudView)
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(viewTapped))
tapGesture.numberOfTapsRequired = 1
self.addGestureRecognizer(tapGesture)
Adding the view to the NavigationBar:
let frame = navigationController!.navigationBar.frame
cloudView = UploadStatusView(frame: CGRect(x: 0, y: 0, width: frame.width * 0.6, height: frame.height))
cloudView.changeLayoutToBeInsideNavigationBar()
cloudView.delegate = self
let cloudViewButton = UIBarButtonItem(customView: cloudView)
self.navigationItem.rightBarButtonItem = cloudViewButton
I expect the event to be relayed, but that's not the case. Instead, nothing happens.