Search code examples
iosiphoneuisplitviewcontroller

How to change color of the separator in UISplitViewController UISplitViewControllerDisplayModePrimaryOverlay mode


I googled all of the related questions , but all the answers are to change color by setting the splitview background color. It did work in UISplitViewControllerDisplayModeAllVisible mode ,but not in UISplitViewControllerDisplayModePrimaryOverlay. Can anybody help me ? Thank you very much!


Solution

  • Here is my answer, Add a 1px line in splitviewcontroller

    _seperateView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 1.0 / [UIScreen mainScreen].scale, CGRectGetHeight(self.view.frame)+20)];

    _seperateView.image = [UIImage imageNamed:@"seprateLine"]

    [self.view insertSubview:_seperateView atIndex:0];

    and layout it frame in viewWillLayoutSubviews

    • (void)viewWillLayoutSubviews {

    _seperateView.left = _masterNav.view.width + _masterNav.view.left;

    }