在iPhone中从PrimaryOverlayanimation到PrimaryHidden时,隐藏UiSplitView中的灰色框

这里有很多答案,描述了如何以编程方式为主要分割视图设置animation:

let addButton = self.splitViewController!.displayModeButtonItem() UIApplication.sharedApplication().sendAction(addButton.action, to: addButton.target, from: nil, forEvent: nil) 

在iPad上,这个function奇妙! 但是在iPhone上,这个令人讨厌的灰色框勾勒出主要视图。 通过将这个动作封装在一个UIView.animate块中,可以很清楚地看到它:

灰色框

当你通过点击细节视图实际上closures主视图时,该框几乎不可见,但是当你以编程方式closures它时真的很烦人。

我怎样才能消除这个烦人的看法?

在我_UIPopoverSlidingChromeView了几天之后,我发现一个相关的答案显示罪魁祸首是_UIPopoverSlidingChromeView视图。 我能find的唯一解决scheme类似于上述主题的解决scheme:在animation期间隐藏该视图。

 var foundChrome = false var view: UIView! = self.view var popView: UIView! let displayModeButton = self.splitViewController!.displayModeButtonItem() while view != nil { //print("View: ", Mirror(reflecting: view).subjectType, " frame: \(view.frame)") if let sv = view { if Mirror(reflecting: sv).description.containsString("Popover") { // _UIPopoverView for v in sv.subviews { //print("SV: ", Mirror(reflecting: v).subjectType, " frame: \(v.frame)") if Mirror(reflecting: v).description.containsString("Chrome") { foundChrome = true popView = v popView.hidden = true break } } if foundChrome { break } } } view = view.superview } if foundChrome { let duration: NSTimeInterval = 2.0 UIView.animateWithDuration(duration, animations: { () -> Void in UIApplication.sharedApplication().sendAction(displayModeButton.action, to: displayModeButton.target, from: nil, forEvent: nil) }) // must do this separately, doing in a completion block doesn't work, as it takes affect too soon let t = dispatch_time(DISPATCH_TIME_NOW, Int64(duration * NSTimeInterval(NSEC_PER_SEC))) dispatch_after(t, dispatch_get_main_queue()) { popView.hidden = false } } 

我意识到这有些深奥,但是如果你遇到这个问题,你会很乐意以任何方式来解决它。