iOS UINavigationBar button remains faded after segue back

前端 未结 4 1777
时光说笑
时光说笑 2020-11-27 20:43

In my app I have multiple view controllers, and most have a right-hand-side UIBarButtonItem with direct \"show\" segue actions attached.

Having segued t

4条回答
  •  感情败类
    2020-11-27 21:12

    Another work around is to implement the fix on the parent navigationController - so that each of its child viewController's gets the fix as follows

    NOTE: This requires the receiving class to be setup as the UINavigationController delegate

    Swift

    func navigationController(_ navigationController: UINavigationController, willShow viewController: UIViewController, animated: Bool) {
        if #available(iOS 11.2, *) {
            navigationBar.tintAdjustmentMode = .normal
            navigationBar.tintAdjustmentMode = .automatic
        }
    }
    

    Objective-C

    -(void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated {    
        if (@available(iOS 11.2, *)) {
            self.navigationBar.tintAdjustmentMode = UIViewTintAdjustmentModeNormal;
            self.navigationBar.tintAdjustmentMode = UIViewTintAdjustmentModeAutomatic;
        }
    }
    

提交回复
热议问题