Swift 3: Back gesture

I have in my Swift 3 application a homeViewController containing a UITableView. When a cell of the table is clicked, then I display a detailViewController. I display it as a child using the

addChildViewController(vc)

. I want to implement the back gesture in order to return to the homeViewController. I want to have the same result as the back mode in the default Mail application of the devices (the back mode to return to the mail's home when I was in the inbox for example). In other words, the gesture allows the user to drag the view from left to right then continuing the left to right drag until the home view is showed, or drag the view from right to left in order to keep the detail view in the whole screen. I tried to do that using the

UIPanGestureRecognizer

but my view goes left and right and sometimes its show the home view from the right side. So in brief, the result that I want is the same as the back gesture functionality of the Mail application.