Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Background View overlaps Left/RightNavigationItems #10

Open
EstebanVallejo opened this issue Mar 27, 2017 · 1 comment
Open

Background View overlaps Left/RightNavigationItems #10

EstebanVallejo opened this issue Mar 27, 2017 · 1 comment

Comments

@EstebanVallejo
Copy link

EstebanVallejo commented Mar 27, 2017

Hello!

I'm having an issue when I'm coming back (pop) to a UIViewController that has left and/or right navigationItems. When I wire the RainbowNavigation to the UIViewController navigationController, set the "navigationBarInColor()", and pop back to that viewController (dragging or not), the colored background view overlaps the navigationItems (except the title or titleView).

override func viewDidLoad() {
        super.viewDidLoad()

        let button = UIBarButtonItem(title: "HELLO", style: .plain, target: nil, action: nil)
        self.navigationItem.setRightBarButton(button, animated: true)

        if let navigationController = navigationController {
            rainbowNavigation.wireTo(navigationController: navigationController)
        }
}

...

func navigationBarInColor() -> UIColor {
        return navColor
}

I have tested it in my own app as in the ExamleApp, and it happens on both.
I have been able to debug it, and found that the navigatinoBar.subviews order is the problem, when poping back the ViewController, the layers are rearranged and the backgroundView place itself over the NavigationItems and behind the (TitleView or Title).

I was not able to fix it yet, has anyone encountered this problem too???

@fwx
Copy link

fwx commented Dec 27, 2017

I know that's an old question, but I managed to fix this.

UINavigationBar+Rainbow.swift

at public var backgroundColor there's an insertSubview function, so I changed it to code below. Not sure how much this would work lol.

if #available(iOS 11, *) {
     navigationBar.subviews[0].insertSubview(navigationView!, at: 0)
} else {
      navigationBar.insertSubview(navigationView!, at: 0)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants