UISplitViewController:删除分隔线
在 iPad 上使用 UISplitViewController 时,根视图和详细视图之间有一条黑色垂直分隔线。有什么办法去掉这条线吗?
谢谢
When using UISplitViewController on the iPad there's a black vertical divider line between the root and detail view. Is there any way to remove this line?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(13)
@bteapot 的出色回答。我对此进行了测试,它有效,甚至消除了主/详细导航栏之间的界限。
您可以在 Storyboard 中通过将“gutterWidth”键路径和值 0 添加到 USplitViewController 运行时属性来执行此操作。
Excellent answer by @bteapot. I tested this and it works, even gets rid of the line between master/detail nav bars.
You can do this in storyboard by adding the "gutterWidth" key path and the value 0 to the USplitViewController runtime attributes.
实际上,我对 appDelegate 中 (Dylan) 的答案进行了一些修改,
我们需要在 spliteview 控制器中添加图像,而不是在
此处添加图像, self 是 AppDelegate 的对象。
现在应用此线程的答案:iPhoneOS SDK - 删除圆角来自视图(iPad问题)由(abs)回答,
在上面的帖子的答案中编辑是
**将imgView.hidden设置为FALSE
将 imgView 声明到 AppDelegate.h 文件**
并且不要忘记调用它
Actuly I have some modification to answer of (Dylan)'s answer
in the appDelegate we need to add image in spliteview controller rather then window
here self is object of AppDelegate.
now Apply the answer of this thread : iPhoneOS SDK - Remove Corner Rounding from views (iPad problem) answer by (abs)
edit in above post's answer is
** make imgView.hidden to FALSE
declare imgView to the AppDelegate.h file**
and dont forget to call this
chintan adatiya 答案仅覆盖角落和导航栏,但我找到了一个技巧,如何覆盖主视图和详细视图之间的界限。
它并不好,但它就像一个魅力。
首先创建一个宽 1 像素、高 704 像素的图像。
在didFinishLaunchingWithOptions中添加以下代码:
完成。
当您想要连续的背景图像时,创建 3 个图像:
chintan adatiya answer covers only the corners and the navigation bar, but I found an trick how to cover the line between the Master and the Detail view.
It is not nice but it works like a charm.
First create an image which is 1 px wide and 704 pixels high.
In the didFinishLaunchingWithOptions add the following code:
And done.
When you want a background image which is continues create 3 images:
第一次发帖,大家好。
当我试图找出为什么我丢失了分隔线时,我意外地发现了如何做到这一点。如果您仍然感兴趣,以下是隐藏它的方法:
1) 在详细信息(右侧)视图中,确保您有一个跨越整个视图的子视图。
2) 将此子视图视图偏移到(-1, 0)。
3) 确保细节视图的“剪辑子视图”选项未选中。
瞧,享受吧。
First post here, hi everyone.
I discovered how to do it accidentally... when I tried to find why I had LOST the divider line. Here's how to hide it, if you're still interested:
1) In your Detail (right-side) view, make sure you have a subview that spans the whole view.
2) Offset this subview view to (-1, 0).
3) Make sure that the Detail View has its "Clip Subviews" option unchecked.
Voilà, enjoy.
您可以通过在主窗口视图中在其后面设置另一个图像来摆脱它。这是来自应用程序委托
didFinishLaunchingWithOptions
但它仍然在顶部和底部留下两个视觉工件,它们似乎是由 splitviewcontroller 自定义绘制的。
You can mostly get rid of it by setting another image behind it in the main window's views. This is from the app delegate
didFinishLaunchingWithOptions
But it still leaves two visual artifacts at the top and the bottom that appear to be custom drawn by the splitviewcontroller.
有趣的是,在我正在开发的应用程序中,我希望 UISplitViewController 中的两个视图都有黑色背景色。我想将分隔线的颜色更改为白色(以便您可以看到它)。将两种背景颜色设为黑色是消除(使其不可见)分界线的一种方法,但这对于大多数人来说可能不是解决方案。
Interestingly, In the app that I'm working on I want a black background color for both views in the UISplitViewController. I'd like to change the color of the divider line to white (so that you can see it). Making both background colors black is one way to get rid of (make invisible) the dividing line but that's probably not a solution for most people.
在 iOS10 上测试(可能也适用于 iOS9)。
它删除了分隔线。显然,分隔符只是主容器和细节容器之间的间隙。
Tested on iOS10 (probably will work on iOS9 too).
it removes divider. Apparently divider is just a gap between master and detail container.
我环顾四周,得出的结论是,除了创建自己的自定义分割视图之外,没有办法做到这一点。
I looked around for a while, and came to the conclusion that theres no way to do this, other than to create your own custom split view.
尝试 Matt Gammell 的 MGSplitViewController
http://mattgemmell.com/2010/07/31 /mgsplitviewcontroller-for-ipad
Try the MGSplitViewController by Matt Gammell
http://mattgemmell.com/2010/07/31/mgsplitviewcontroller-for-ipad
我可能会迟到,但是我有一个可行的解决方案。它甚至适用于 iOS 8+ splitViewController.preferredDisplayMode = UISplitViewControllerDisplayModeAllVisible;当您按下全屏切换按钮时,可以无缝滑入和滑出。
这里是技巧:
第一个子类UISplitViewController.m
在标题中添加以下内容:
在viewDidLoad方法中添加以下代码:
在< strong>DetailViewController.h 添加以下内容:
现在这是最后的技巧:在 DetailViewController.m 中,在 viewDidLoad 方法中添加以下内容(每次单击主表时调用) :
运行它并观看魔术;-)
I may be late here, but I DO have a solution that works. It even works for the iOS 8+ splitViewController.preferredDisplayMode = UISplitViewControllerDisplayModeAllVisible; and seamlessly slides in and out when you press the Full Screen toggle button.
Here is the trick :
first Subclass UISplitViewController.m
In the header add the follwing :
In the viewDidLoad method add the following code :
In the DetailViewController.h add the following :
Now here is the final trick : in the DetailViewController.m, add the following in the viewDidLoad method (called every time you click the Master table) :
Run it and watch the magic ;-)
私有 API(可能导致 App Store 拒绝):
Private API (can cause App Store rejection):
我通过设置第一个 viewController 的视图的 backgroundColor 属性意外地做到了这一点 - 可能是clearColor,我现在不记得了。
I did this accidentally by setting the backgroundColor property of the first viewController's view - possibly to clearColor, I don't remember now.
UIManager.put("SplitPaneDivider.draggingColor", new Color(255, 255, 255, 0));
UIManager.put("SplitPaneDivider.draggingColor", new Color(255, 255, 255, 0));