在 iPad 上使用 UISplitViewController 时,根视图和详细视图之间有一条黑色的垂直分隔线。有什么办法可以去掉这条线?
谢谢
在 iPad 上使用 UISplitViewController 时,根视图和详细视图之间有一条黑色的垂直分隔线。有什么办法可以去掉这条线?
谢谢
实际上,我对(Dylan)的回答有一些修改
在 appDelegate 中,我们需要在 spliteview 控制器而不是窗口中添加图像
self.splitViewController.view.opaque = NO;
imgView = [[UIImageView alloc] initWithImage:
[UIImage imageNamed:@"FullNavBar.png"]];
[imgView setFrame:CGRectMake(0, 0, 1024, 44)];
[[self.splitViewController view] insertSubview:imgView atIndex:0];
[[self.splitViewController view] setBackgroundColor:[UIColor clearColor]];
这里 self 是 AppDelegate 的对象。
现在应用此线程的答案:iPhoneOS SDK - Remove Corner Rounding from views (iPad question)由(abs)回答
在上面的帖子中编辑的答案是
-(void) fixRoundedSplitViewCorner {
[self explode:[[UIApplication sharedApplication] keyWindow] level:0];
}
-(void) explode:(id)aView level:(int)level
{
if ([aView isKindOfClass:[UIImageView class]]) {
UIImageView* roundedCornerImage = (UIImageView*)aView;
roundedCornerImage.hidden = YES;
}
if (level < 2) {
for (UIView *subview in [aView subviews]) {
[self explode:subview level:(level + 1)];
}
}
imgView.hidden = FALSE;
}
** 使 imgView.hidden 为 FALSE 将 imgView 声明到 AppDelegate.h 文件**
别忘了叫这个
-(void)didRotateFromInterfaceOrientation:
UIInterfaceOrientation)fromInterfaceOrientation
{
[yourAppDelegate performSelector:@selector(fixRoundedSplitViewCorner)
withObject:NULL afterDelay:0];
}
chintan adatiya 答案仅涵盖角落和导航栏,但我发现了一个技巧,如何覆盖 Master 和 Detail 视图之间的界限。
这不是很好,但它就像一个魅力。
首先创建一个 1 px 宽和 704 像素高的图像。
在 didFinishLaunchingWithOptions 添加以下代码:
UIView *coverView = [[UIView alloc] initWithFrame:CGRectMake(320, 44, 1, 704)];
[coverView setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"divider_cover.png"]]];
[splitViewController.view addSubview:coverView];
并做了。
当您想要一个继续创建 3 个图像的背景图像时:
第一次发帖,大家好。
我意外地发现了如何做到这一点......当我试图找出为什么我丢失了分隔线时。如果您仍然感兴趣,以下是隐藏它的方法:
1)在您的细节(右侧)视图中,确保您有一个跨越整个视图的子视图。
2) 将此子视图视图偏移到 (-1, 0)。
3) 确保详细视图的“剪辑子视图”选项未选中。
瞧,享受吧。
您可以通过在主窗口的视图中设置另一个图像来摆脱它。这是来自应用程序委托didFinishLaunchingWithOptions
// Add the split view controller's view to the window and display.
splitViewController.view.opaque = NO;
splitViewController.view.backgroundColor = [UIColor clearColor];
[window addSubview:splitViewController.view];
[window insertSubview:bgImageView belowSubview:splitViewController.view];
[window makeKeyAndVisible];
但它仍然在顶部和底部留下两个视觉工件,看起来是由 splitviewcontroller 自定义绘制的。
有趣的是,在我正在开发的应用程序中,我希望 UISplitViewController 中的两个视图都使用黑色背景色。我想将分隔线的颜色更改为白色(以便您可以看到它)。将两种背景颜色都设为黑色是摆脱(使不可见)分界线的一种方法,但这可能不是大多数人的解决方案。
在 iOS10 上测试(可能也适用于 iOS9)。
splitviewController.view.backgroundColor = UIColor.white
它删除了分隔符。显然分隔符只是主容器和细节容器之间的差距。
试试 Matt Gammell 的 MGSplitViewController
http://mattgemmell.com/2010/07/31/mgsplitviewcontroller-for-ipad
我可能会迟到,但我确实有一个可行的解决方案。它甚至适用于 iOS 8+ splitViewController.preferredDisplayMode = UISplitViewControllerDisplayModeAllVisible;并在您按下全屏切换按钮时无缝滑入和滑出。
这是诀窍:
第一个子类UISplitViewController.m
在标题中添加以下内容:
@property (strong, nonatomic) UIView *fakeNavBarBGView;
在viewDidLoad方法中添加以下代码:
CGFloat fakeNavBarWidth = 321; // It is important to have it span the width of the master view + 1 because it will not move when the split view slides it's subviews (master and detail)
CGFloat navbarHeight = self.navigationController.navigationBar.frame.size.height + 20;
self.fakeNavBarBGView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, fakeNavBarWidth, navbarHeight)];
self.fakeNavBarBGView.backgroundColor = [UIColor redColor];
// Add Fake navbar to back of view
[self.view insertSubview:self.fakeNavBarBGView atIndex:0];
// SplitView Controller
UISplitViewController *splitViewController = self;
DetailViewController *detailVC = [navigationController.viewControllers lastObject];
detailVC.fakeNavBarSubView = self.fakeNavBarBGView;
detailVC.SVView = self.view;
在DetailViewController.h添加以下内容:
@property (strong, nonatomic) UIView *SVView;
@property (strong, nonatomic) UIView *fakeNavBarSubView;
现在这是最后的技巧:在DetailViewController.m中,在 viewDidLoad 方法中添加以下内容(每次单击 Master 表时都会调用):
[self.SVView sendSubviewToBack:self.fakeNavBarSubView];
[self.SVView bringSubviewToFront:self.view];
运行它并观看魔术;-)
我环顾了一会,得出的结论是,除了创建自己的自定义拆分视图之外,没有其他方法可以做到这一点。
私有 API(可能导致 App Store 拒绝):
[splitViewController setValue:@0.0 forKey:@"gutterWidth"];
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));