Using Swift 5.1.3, iOS13.3, XCode11.3,
I try to create a custom navigationBar Title and use the navigationItem.titleView to do so.
Everything works fine if the custom titleView is of small size (around 40-45 pixels). The reason is most likely because of the fact that a navigationItem right-left button is also of that small size.
However, my naviagionBar is set up as a large Title and I would like to place a taller custom titleView to fill that large space.
I find a lot of answers for custom naviagationItem.titleView's (such as the following code). But unfortunately these solutions do not help for taller heights !
Here is a solution for small heights:
var titleView = UIView(frame: CGRect(x: 0, y: 0, width: 100, height: 40))
var titleImageView = UIImageView(image: UIImage(named: "headerlogo"))
titleImageView.frame = CGRect(x: 0, y: 0, width: titleView.frame.width, height: titleView.frame.height)
titleView.addSubview(titleImageView)
navigationItem.titleView = titleView
If the height is 150 or 250 this solution does not work - especially if the custom titleView contains a button. The button is no longer clickable since the click event is no longer recognised at lower edges of the custom titleView !
Problem 1: Button click events are no longer recognised if you place items inside the large-height custom navigationItem.titleView.
Problem 2: When navigation back from a detail-VC into your VC containing the large-title custom navigationItem.titleView - then our custom titleView disappears entirely.
How to overcome Problems 1 & 2 - that is the question here. Thanks for any help on this.
P.S. Here is an illustration of the desired result. The navigationItem.titleView is custom and contains a stackView with two elements (i.e. title-Text and a round yellow Button). The custom titleView shall be placed at the very bottom of the navigationBar, but again still overcoming problem 1 & 2 as desscribed above !