There are numerous answers here that describe how to programmatically animate the primary split view:
let addButton = self.splitViewController!.displayModeButtonItem()
UIApplication.sharedApplication().sendAction(addButton.action, to: addButton.target, from: nil, forEvent: nil)
On an iPad this works wonderfully! But on an iPhone there is this annoying gray box that trails the primary view. By wrapping that action in a UIView.animate block, its possible to see it quite clearly:
The box is hardly visible when you actually dismiss the primary view by tapping over the detail view, but is really annoying when you programmatically dismiss it.
How can I remove this annoying view?
After banging my head on this for several days, I found a related answer that showed the culprit is the
_UIPopoverSlidingChromeView
view. The only solution I could find is similar to the solution of the above topic: to hide that view during the animation.I realize this is somewhat esoteric, but if you experience the problem you will be happy for any way to work around it.