UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

Custom (UIview)menu Bar won't show up

Forums > SwiftUI

at the moment im trying to make a custom menu bar thats designed like youtubes at the top but i cant even get the uiview to show up can somebody tell me whats wrong I am trying to get it to where it shows right under the navigationtitle(Closet)

class ClosetViewController: UIViewController, UICollectionViewDelegate {

    @IBOutlet var collectionView: UICollectionView!

        let headerId = "headerId"
        let arrImages = ["image1","image1","image1"]
    let categoryHeaderId = "categoryHeaderId"

        override func viewDidLoad() {
            super.viewDidLoad()

            navigationItem.title = "Closet"
            navigationController?.navigationBar.isTranslucent = false

            let titleLabel = UILabel(frame: CGRect(x: 0, y: 0, width: view.width, height:view.height))
            titleLabel.text = "Closet"
            titleLabel.textColor = .white

            navigationItem.titleView = titleLabel
            collectionView.dataSource = self
            collectionView.delegate = self
            collectionView.register(ClosetCollectionViewCell.self, forCellWithReuseIdentifier: ClosetCollectionViewCell.reuseIdentifer)

            collectionView.register(ClosetReusableView.self, forSupplementaryViewOfKind: categoryHeaderId, withReuseIdentifier: headerId)
            collectionView.collectionViewLayout = createCompositionalLayout()

            collectionView.reloadData()

            let menuBar = UIView()
            menuBar.translatesAutoresizingMaskIntoConstraints = false
            menuBar.backgroundColor = .red
            menuBar.sizeToFit()
            view.addSubview(menuBar)

        }

2      

BUILD THE ULTIMATE PORTFOLIO APP Most Swift tutorials help you solve one specific problem, but in my Ultimate Portfolio App series I show you how to get all the best practices into a single app: architecture, testing, performance, accessibility, localization, project organization, and so much more, all while building a SwiftUI app that works on iOS, macOS and watchOS.

Get it on Hacking with Swift+

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.