ios 11 custom navbar goes under status bar

前端 未结 5 1692
刺人心
刺人心 2020-11-28 13:31

just downloaded xcode 9 and i\'m having this weird issue, on ios 11 my custom navbar appears to be half in size and is under the status bar, on ios 10 works fine.

so

5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-28 14:31

    Tried this solution in Swift 4.1

    let menuBar: UIView = {
    let mb = UIView()
    mb.backgroundColor = .red
    mb.translatesAutoresizingMaskIntoConstraints = false
    return mb
    }()
    
    
    
    private func setupMenuBar(){
    
    view.addSubview(menuBar)
    
    let constraints = [ menuBar.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor),
                        menuBar.leadingAnchor.constraint(equalTo: view.leadingAnchor),
                        menuBar.trailingAnchor.constraint(equalTo: view.trailingAnchor),
                        menuBar.heightAnchor.constraint(equalToConstant: 50)]
    NSLayoutConstraint.activate(constraints)
    }
    

提交回复
热议问题