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

childViewControllerForStatusBarStyle and preferredStatusBarStyle don't work. #25

Closed
MQZHot opened this issue Jul 19, 2018 · 3 comments
Closed

Comments

@MQZHot
Copy link
Contributor

MQZHot commented Jul 19, 2018

When I install CocoaDebug, childViewControllerForStatusBarStyle and preferredStatusBarStyle don't work.

@CocoaDebug
Copy link
Owner

If you can paste your code here , it will helps a lot! Thanks.

@MQZHot
Copy link
Contributor Author

MQZHot commented Jul 20, 2018

I customized the navigationController

class NavigationViewController: UINavigationController {
    
    override var childViewControllerForStatusBarStyle: UIViewController? {
        return self.topViewController
    }
    
}

Below is the appDelegate code

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        #if DEBUG
        CocoaDebug.enable()
        #endif
        
        window = UIWindow(frame: UIScreen.main.bounds)
        window?.backgroundColor = .white
        let nav = NavigationViewController(rootViewController: ViewController())
        window?.rootViewController = nav
        window?.makeKeyAndVisible()
        
        return true
    }

Code in viewController

class ViewController: UIViewController, UIScrollViewDelegate {

    var offset: CGFloat = 0
    
    override func viewDidLoad() {
        super.viewDidLoad()
        let scrollView = UIScrollView(frame: view.bounds)
        scrollView.contentSize = CGSize(width: UIScreen.main.bounds.size.width, height: 1000)
        scrollView.delegate = self
        view.addSubview(scrollView)
    }
    override var preferredStatusBarStyle: UIStatusBarStyle {
        return offset >= 1 ? .lightContent : .default
    }
    func scrollViewDidScroll(_ scrollView: UIScrollView) {
        let offsetY = scrollView.contentOffset.y/100
        offset = offsetY
        setNeedsStatusBarAppearanceUpdate()
    }
}

MQZHot added a commit to MQZHot/CocoaDebug that referenced this issue Jul 21, 2018
@CocoaDebug
Copy link
Owner

CocoaDebug commented Jul 22, 2018

New version published, please update.

@MQZHot MQZHot closed this as completed Jul 23, 2018
@CocoaDebug CocoaDebug added the bug Something isn't working label Jul 23, 2018
@CocoaDebug CocoaDebug removed the bug Something isn't working label Apr 2, 2019
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