简体   繁体   中英

How to change Status Bar Style of PushRow View Controller?

I have got the answer if I am using latest pod of Eureka which supports swift 4. https://github.com/xmartlabs/Eureka/issues/1355#issuecomment-353334726

But I am on branch swift 3.2

When I use the solution given in the above link

class MyPushViewController: SelectorViewController<SelectorRow<PushSelectorCell<String>>> {

    override var preferredStatusBarStyle: UIStatusBarStyle {
        return .lightContent
    }
}

I get error "Generic type 'SelectorRow' specialized with too few type parameters (got 1, but expected 2)"

The error you got is about SelectRow generic type. It required 2 type parameters:

<SelectRow<PushSeletorCell<String>, second type here>

Example from Eureka:

public final class CustomPushRow<T: Equatable>: SelectorRow<PushSelectorCell<T>, SelectorViewController<T>>, RowType { 
    public required init(tag: String?) { 
        super.init(tag: tag) 
        presentationMode = .show(controllerProvider: ControllerProvider.callback { 
            return SelectorViewController<T>(){ _ in } 
        }, onDismiss: { vc in 
            _ = vc.navigationController?.popViewController(animated: true) 
        }) 
    } 
}

As you can see, SelectRow required 2 type params: PushSelectorCell<T> and SelectorViewController<T>

I tried to get custom rows working but after almost 2 hours of experiments I've achieved nothing. Random template errors, it reminded me template hell from cpp.

Here is a workaround for tired people like me:

class CustomNavigationController: UINavigationController {
  override var preferredStatusBarStyle: UIStatusBarStyle {
    // force status bar style for Eureka forms
    if topViewController is FormViewController {
      return .lightContent
    }
    return topViewController?.preferredStatusBarStyle ?? .default
  }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM