양홍범
양홍범

Reputation: 87

swift - How to make size height view in navigation controller?

I want to ignore navigation bar and make full size view in navigation controller. But the view is shown under the navigation bar. Could I overlap navigation bar with black view?

enter image description here

I want to make like this picture enter image description here

Upvotes: 0

Views: 620

Answers (1)

Chanchal Chauhan
Chanchal Chauhan

Reputation: 1560

To achieve the given UI you should add the top view on window.To do so, First make an xib of top view. then add given code:

    let frame = UIApplication.shared.keyWindow?.frame
    let wrapper = UIView(frame: frame!)
    wrapper.backgroundColor = UIColor.black.withAlphaComponent(0.35)

    let objView = YourView() // Create your view object here.
    objView.frame = wrapper.frame
    objView.center = wrapper.center
    wrapper.addSubview(objView)

    UIApplication.shared.keyWindow?.addSubview(wrapper)

Set frame of YourView according to your requirement. wrapper makes your view transparent. You can make single view without wrapper. Use same code to add your view on window.

Upvotes: 2

Related Questions