Hello Team we facing a problem with a UIView inside of a Navigation Bar what we need to achieve is to place a UIView (SwiftUI Wrapper) on the middle of the Navigation bar Here's how it looks like right now
that's already complete, but now the problem that we are facing is that the View is not detecting the clicks/taps on the 'dates and 'travelers'
here's the Code for the View
private lazy var sharedUIPlaybackView: UIView = {
let containerView = UIView().withAutoLayout()
containerView.backgroundColor = .red
containerView.styleBorder(color: .systemPink, width: 1)
let propertySearchCriteria = PropertySearchCriteriaBuilder(hotelSearchParameters: viewModel.hotelSearchParameters).criteria
var swiftUIView: SwiftUIView<LodgingPlaybackWrapper>! = nil
swiftUIView = SwiftUIView(
LodgingPlaybackWrapper(propertySearchCriteria: propertySearchCriteria,
playbackUpdateNotificationSender: nil,
componentHandler: { [weak self] componentId in
self?.componentReady(componentId)
}),
viewDidLayoutSubviewsCallback: { [weak self] in
let newHeight = swiftUIView.frame.size.height
if newHeight != self?.sharedUIPlaybackViewHeightConstraint?.constant {
self?.sharedUIPlaybackViewHeightConstraint?.constant = newHeight
self?.additionalSafeAreaInsets.top = 200
}
}
).withAutoLayout().withAccessibilityIdentifier("searchPlayback")
sharedUIPlaybackViewHeightConstraint = containerView.heightAnchor.constraint(equalToConstant: 0)
sharedUIPlaybackViewHeightConstraint?.isActive = true
swiftUIView.backgroundColor = .blue
swiftUIView.styleBorder(color: .orange, width: 1)
containerView.addSubview(swiftUIView)
containerView.addConstraints([
swiftUIView.leadingAnchor.constraint(equalTo: containerView.leadingAnchor, constant: Spacing.spacing4x),
swiftUIView.trailingAnchor.constraint(equalTo: containerView.trailingAnchor, constant: -Spacing.spacing4x)
])
self.view.bringSubviewToFront(swiftUIView)
swiftUIView.isUserInteractionEnabled = true
swiftUIView.layer.zPosition = 1
return containerView
}()
my first suspicion was that the this part of the code was not expanding correctly
viewDidLayoutSubviewsCallback: { [weak self] in
let newHeight = swiftUIView.frame.size.height
if newHeight != self?.sharedUIPlaybackViewHeightConstraint?.constant {
self?.sharedUIPlaybackViewHeightConstraint?.constant = newHeight
self?.additionalSafeAreaInsets.top = 200
}
}
but after I place border and background colors on the views was clear for me that it was expanding properly, so I added some modifiers for the view like
swiftUIView.isUserInteractionEnabled = true
swiftUIView.layer.zPosition = 1
but didn't work, I'm asking for a solution and different point of view for the code to be more cleaner and do the best implementation posible. This Navigation bar should be treated as a custom Navigation Bar, or it is good for us to expand and treat the Navigation bar like this? (expanding and adding a Custom View)
thanks in advance to anyone who read this. here's the View Hierarchy