iosswiftuinavigationbarlarge-title

Large navigation bar custom height


Is it possible to change large navigation bar height?

self.navigationItem.largeTitleDisplayMode = .always 
self.navigationController?.navigationBar.prefersLargeTitles = true
self.navigationController?.navigationBar.addSubview(expandedNavBar)

Solution

  • Ok, I found this way:

    let paragraphStyle = NSMutableParagraphStyle()
    paragraphStyle.minimumLineHeight = 200
    let attributes: [NSAttributedString.Key: Any] = [ .paragraphStyle: paragraphStyle]
    
    let navigationBar = navigationController?.navigationBar
    if #available(iOS 13, *) {
        if let appearance = navigationBar?.standardAppearance {
            appearance.largeTitleTextAttributes = attributes
            navigationBar?.standardAppearance = appearance
            navigationBar?.scrollEdgeAppearance = appearance
        }
    } else {
        navigationBar?.largeTitleTextAttributes = attributes
    }