Skip to content

The back button text color changed from transparent to black. - #394

Merged
andreamazz merged 1 commit into
andreamazz:masterfrom
y-okudera:master
Jul 16, 2020
Merged

The back button text color changed from transparent to black.#394
andreamazz merged 1 commit into
andreamazz:masterfrom
y-okudera:master

Conversation

@y-okudera

Copy link
Copy Markdown
Contributor

Hi, @andreamazz
Thank you for the cool library.

After hiding the navigation bar, the back button text color changed from transparent to black.
And I solved the problem.

Before After
before after

Updating the navigation appearance in sample app is the following.

extension UINavigationController {
    func setupCustomNavigation() {
        let clear = [NSAttributedString.Key.foregroundColor: UIColor.clear]

        if #available(iOS 13.0, *) {
            let barAppearance = UINavigationBarAppearance()

            // Hide back button title.
            let barButtonAppearance = UIBarButtonItemAppearance()
            barButtonAppearance.normal.titleTextAttributes = clear
            barButtonAppearance.highlighted.titleTextAttributes = clear
            barAppearance.backButtonAppearance = barButtonAppearance

            // Set NavigationBar background color.
            barAppearance.backgroundColor = .yellow

            self.navigationBar.standardAppearance = barAppearance
            self.navigationBar.isTranslucent = false
        }
        else {
            // Hide back button title.
            UIBarButtonItem
                .appearance(whenContainedInInstancesOf: [UINavigationBar.self])
                .setTitleTextAttributes(clear, for: .normal)

            UIBarButtonItem
                .appearance(whenContainedInInstancesOf: [UINavigationBar.self])
                .setTitleTextAttributes(clear, for: .highlighted)

            // Set NavigationBar background color.
            self.navigationBar.barTintColor = .yellow
            self.navigationBar.isTranslucent = false
        }
    }
}

Best regards,

@y-okudera y-okudera changed the title The back button text color changed from transparent to black on iOS 13. The back button text color changed from transparent to black. Jul 15, 2020
@y-okudera

Copy link
Copy Markdown
Contributor Author

This issue also occurs on non-iOS 13, so I updated the title.

@andreamazz

Copy link
Copy Markdown
Owner

Nice catch, thanks for your contribution!

@andreamazz
andreamazz merged commit 7f4da39 into andreamazz:master Jul 16, 2020
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

Successfully merging this pull request may close these issues.

2 participants