开发者

How to change divider color in iOS for UISplitView

Is it possible to change the color of the divider? If so, how?

I've researched as much as possible here and on Google,开发者_如何学C without luck. I'm surprised it isn't more common...

Thanks


On iOS 7, the fix is to set the background color of your UISplitViewController to the same as the deep background color (probably black).


There is a quicker and better way of doing it. Just change spliViewController's view backgroundColor property:

    splitViewController.view.backgroundColor = [UIColor greenColor];


In the detailViewController of the SplitViewController, I added the following code to cover up the black line. My custom header is blue and 88px tall.

//blue line that covers the vertical black separator in the header
UIView *blueHeaderSplitViewSeparatorMask = [[UIView alloc] initWithFrame:CGRectMake(320, 0, 2, 88)];
[blueHeaderSplitViewSeparatorMask setBounds:CGRectMake(320, 0, 2, 88)];
[blueHeaderSplitViewSeparatorMask setBackgroundColor:[UIColor colorWithRed:0.0f/255.0f green:96.0f/255.0f blue:182.0f/255.0f alpha:1.0f]];
[self.view.superview addSubview:blueHeaderSplitViewSeparatorMask];


You mean the one-point line between the left and right view controllers? No, UISplitViewController doesn’t expose a way to change that. You might try creating an opaque view with the same size as the split view controller’s view and its backgroundColor set to the color you want, then add it below the other two controllers’ views like this:

splitController.viewControllers = [NSArray arrayWithObjects:leftController, rightController, nil];
[splitController.view insertSubview:theBackgroundView atIndex:0];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜