{"id":293998,"date":"2019-08-29T15:00:15","date_gmt":"2019-08-29T15:00:15","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=293998"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=293998","title":{"rendered":"\u041d\u0435 \u0432\u0441\u043f\u043b\u044b\u0432\u0430\u0439! \u041f\u0440\u0435\u0440\u044b\u0432\u0430\u0435\u043c\u044b\u0435 \u0442\u0440\u0430\u043d\u0437\u0438\u0448\u0435\u043d\u044b \u0432\u00a0iOS"},"content":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\">\n<p>\u0412\u0430\u0441 \u0442\u043e\u0436\u0435 \u0431\u0435\u0441\u044f\u0442 \u0432\u0441\u043f\u043b\u044b\u0432\u0430\u044e\u0449\u0438\u0435 \u043e\u043a\u043d\u0430 \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445? \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u043f\u043e\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u0438\u043d\u0442\u0435\u0440\u0430\u043a\u0442\u0438\u0432\u043d\u043e \u0441\u043a\u0440\u044b\u0432\u0430\u0442\u044c \u0438 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0432\u0441\u043f\u043b\u044b\u0432\u0430\u044e\u0449\u0438\u0435 \u043e\u043a\u043d\u0430, \u0434\u0435\u043b\u0430\u0442\u044c \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044e \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u0435\u043c\u043e\u0439 \u0438 \u043d\u0435 \u0431\u0435\u0441\u0438\u0442\u044c \u0441\u0432\u043e\u0438\u0445 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432.<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/dm\/no\/2f\/dmno2fidzesnqjrc1wozmragwsc.png\"><\/p>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<p><a href=\"https:\/\/habr.com\/ru\/company\/dodopizzaio\/blog\/463527\/\">\u0412 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435<\/a> \u044f \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0430\u043d\u0438\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430. <\/p>\n<p>  <\/p>\n<p>\u041c\u044b \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0438\u0441\u044c \u043d\u0430 \u0442\u043e\u043c, \u0447\u0442\u043e <code>viewController<\/code> \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u0438 \u0441\u043a\u0440\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u0430\u043d\u0438\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u043e:<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/im\/ri\/hb\/imrihb1jvnv2hr0axyha7n1f_ea.gif\"><\/p>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u0443\u0447\u0438\u043c \u0435\u0433\u043e \u0440\u0435\u0430\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430 \u0436\u0435\u0441\u0442 \u0441\u043a\u0440\u044b\u0442\u0438\u044f. <\/p>\n<p>  <\/p>\n<h2 id=\"interaktivnyy-tranzishen\">\u0418\u043d\u0442\u0435\u0440\u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u0442\u0440\u0430\u043d\u0437\u0438\u0448\u0435\u043d<\/h2>\n<p>  <\/p>\n<h3 id=\"dobavlyaem-zhestzakrytiya\">\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0436\u0435\u0441\u0442\u00a0\u0437\u0430\u043a\u0440\u044b\u0442\u0438\u044f<\/h3>\n<p>  <\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u043d\u0430\u0443\u0447\u0438\u0442\u044c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u0438\u043d\u0442\u0435\u0440\u0430\u043a\u0442\u0438\u0432\u043d\u043e, \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0436\u0435\u0441\u0442 \u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0435\u0433\u043e. \u0412\u0441\u044f \u0440\u0430\u0431\u043e\u0442\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 <code>TransitionDriver<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"swift\">class TransitionDriver: UIPercentDrivenInteractiveTransition     func link(to controller: UIViewController) {         presentedController = controller         panRecognizer = UIPanGestureRecognizer(target: self, action: #selector(handle(recognizer:)))         presentedController?.view.addGestureRecognizer(panRecognizer!)     }      private var presentedController: UIViewController?     private var panRecognizer: UIPanGestureRecognizer?<\/code><\/pre>\n<p>  <\/p>\n<p>\u041c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0441\u043e\u0435\u0434\u0438\u043d\u0438\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0432 \u043c\u0435\u0441\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f DimmPresentationController, \u0432\u043d\u0443\u0442\u0440\u0438 PanelTransition:<\/p>\n<p>  <\/p>\n<pre><code class=\"swift\">private let driver = TransitionDriver()  func presentationController(forPresented presented: UIViewController, presenting: UIViewController?, source: UIViewController) -&gt; UIPresentationController? {      driver.link(to: presented)      let presentationController = DimmPresentationController(presentedViewController: presented, presenting: presenting)      return presentationController }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0440\u0438 \u044d\u0442\u043e\u043c, \u043d\u0443\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u0441\u043a\u0440\u044b\u0442\u0438\u0435 \u0441\u0442\u0430\u043b\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u043c (\u043c\u044b \u0443\u0436\u0435 \u0441\u0434\u0435\u043b\u0430\u043b\u0438 \u044d\u0442\u043e \u0432 \u043f\u0440\u043e\u0448\u043b\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435):<\/p>\n<p>  <\/p>\n<pre><code class=\"swift\">\/\/ PanelTransition.swift  func interactionControllerForDismissal(using animator: UIViewControllerAnimatedTransitioning) -&gt; UIViewControllerInteractiveTransitioning? {     return driver }<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"obrabatyvaem-zhest\">\u041e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u0436\u0435\u0441\u0442<\/h3>\n<p>  <\/p>\n<p>\u041d\u0430\u0447\u043d\u0451\u043c \u0441 \u0436\u0435\u0441\u0442\u0430 \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u044f: \u0435\u0441\u043b\u0438 \u043f\u0430\u043d\u0435\u043b\u044c \u043f\u043e\u0442\u0430\u0449\u0438\u0442\u044c \u0432\u043d\u0438\u0437, \u0442\u043e \u043d\u0430\u0447\u043d\u0451\u0442\u0441\u044f \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044f \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u044f, \u0438 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0435 \u043f\u0430\u043b\u044c\u0446\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u043b\u0438\u044f\u0442\u044c \u043d\u0430 \u0441\u0442\u0435\u043f\u0435\u043d\u044c \u0437\u0430\u043a\u0440\u044b\u0442\u043e\u0441\u0442\u0438.\u00a0<br \/>  <code>UIPercentDrivenInteractiveTransition<\/code> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0438\u0442\u044c \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044e \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430 \u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0435\u0439 \u0432\u0440\u0443\u0447\u043d\u0443\u044e. \u0423 \u043d\u0435\u0433\u043e \u0435\u0441\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b <code>update<\/code>, <code>finish<\/code>, <code>cancel<\/code>. \u0423\u0434\u043e\u0431\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0436\u0435\u0441\u0442\u0430 \u0432 \u0435\u0433\u043e \u0441\u0430\u0431\u043a\u043b\u0430\u0441\u0441\u0435.<\/p>\n<p>  <\/p>\n<h4 id=\"obrabotka-zhesta\">\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0436\u0435\u0441\u0442\u0430<\/h4>\n<p>  <\/p>\n<pre><code class=\"swift\">private func handleDismiss(recognizer r: UIPanGestureRecognizer) {         switch r.state {     case .began:         pause() \/\/ Pause allows to detect isRunning          if !isRunning {                     presentedController?.dismiss(animated: true) \/\/ Start the new one         }      case .changed:         update(percentComplete + r.incrementToBottom(maxTranslation: maxTranslation))      case .ended, .cancelled:         if r.isProjectedToDownHalf(maxTranslation: maxTranslation) {             finish()         } else {             cancel()         }      case .failed:         cancel()      default:         break     } }<\/code><\/pre>\n<p>  <\/p>\n<p><code>.begin<\/code><br \/>  \u041d\u0430\u0447\u0430\u0442\u044c \u0434\u0438\u0441\u043c\u0438\u0441\u0441 \u0441\u0430\u043c\u044b\u043c \u043e\u0431\u044b\u0447\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c. \u0421\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u043c\u044b \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u043b\u0438 \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 <code>link(to:)<\/code><\/p>\n<p>  <\/p>\n<p><code>.changed<\/code><br \/>  \u041f\u043e\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0438\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442. \u0420\u0430\u0441\u0447\u0451\u0442\u044b \u0432\u044b\u043d\u0435\u0441 \u0432 \u044d\u043a\u0441\u0442\u0435\u043d\u0448\u0435\u043d \u0436\u0435\u0441\u0442\u0430, \u0447\u0442\u043e\u0431\u044b \u043a\u043e\u0434 \u0441\u0442\u0430\u043b \u0447\u0438\u0449\u0435.<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0430\u0441\u0447\u0451\u0442\u044b \u0436\u0435\u0441\u0442\u0430<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"swift\">private extension UIPanGestureRecognizer {     func isProjectedToDownHalf(maxTranslation: CGFloat) -&gt; Bool {         let endLocation = projectedLocation(decelerationRate: .fast)         let isPresentationCompleted = endLocation.y &gt; maxTranslation \/ 2          return isPresentationCompleted     }      func incrementToBottom(maxTranslation: CGFloat) -&gt; CGFloat {         let translation = self.translation(in: view).y         setTranslation(.zero, in: nil)          let percentIncrement = translation \/ maxTranslation         return percentIncrement     } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0420\u0430\u0441\u0447\u0451\u0442\u044b \u043e\u043f\u0438\u0440\u0430\u044e\u0442\u0441\u044f \u043d\u0430 <code>maxTranslation<\/code>, \u0435\u0433\u043e \u043c\u044b \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u043c \u043a\u0430\u043a \u0432\u044b\u0441\u043e\u0442\u0443 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"swift\">var maxTranslation: CGFloat {         return presentedController?.view.frame.height ?? 0 }<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p><code>.end<\/code><br \/>  \u0421\u043c\u043e\u0442\u0440\u0438\u043c \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u0436\u0435\u0441\u0442\u0430. \u041f\u0440\u0430\u0432\u0438\u043b\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f: \u0435\u0441\u043b\u0438 \u0441\u043c\u0435\u0441\u0442\u0438\u043b\u043e\u0441\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u044b, \u0442\u043e \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u043c. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u043d\u0430\u0434\u043e \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0435, \u043d\u043e \u0438 \u0443\u0447\u0435\u0441\u0442\u044c <code>velocity<\/code>. \u0422\u0430\u043a \u043c\u044b \u043f\u043e\u0439\u043c\u0451\u043c \u043d\u0430\u043c\u0435\u0440\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f: \u043e\u043d \u043c\u043e\u0433 \u043d\u0435 \u0434\u043e\u0432\u0435\u0441\u0442\u0438 \u0434\u043e \u0441\u0435\u0440\u0435\u0434\u0438\u043d\u044b, \u043d\u043e \u0441\u0432\u0430\u0439\u043f\u043d\u0443\u0442\u044c \u0441\u0438\u043b\u044c\u043d\u043e \u0432\u043d\u0438\u0437. \u0418\u043b\u0438 \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442: \u0443\u0432\u0435\u0441\u0442\u0438 \u0432\u043d\u0438\u0437, \u043d\u043e \u0441\u0432\u0430\u0439\u043f\u043d\u0443\u0442\u044c \u0432\u0432\u0435\u0440\u0445 \u0434\u043b\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0442\u0430.<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0430\u0441\u0447\u0451\u0442\u044b projectedLocation<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"swift\">extension UIPanGestureRecognizer {     func projectedLocation(decelerationRate: UIScrollView.DecelerationRate) -&gt; CGPoint {         let velocityOffset = velocity(in: view).projectedOffset(decelerationRate: .normal)         let projectedLocation = location(in: view!) + velocityOffset         return projectedLocation     } }  extension CGPoint {     func projectedOffset(decelerationRate: UIScrollView.DecelerationRate) -&gt; CGPoint {         return CGPoint(x: x.projectedOffset(decelerationRate: decelerationRate),                       y: y.projectedOffset(decelerationRate: decelerationRate))     } }  extension CGFloat { \/\/ Velocity value     func projectedOffset(decelerationRate: UIScrollView.DecelerationRate) -&gt; CGFloat {         \/\/ Magic formula from WWDC         let multiplier = 1 \/ (1 - decelerationRate.rawValue) \/ 1000         return self * multiplier     } }  extension CGPoint {     static func +(left: CGPoint, right: CGPoint) -&gt; CGPoint {         return CGPoint(x: left.x + right.x,                       y: left.y + right.y)     } }<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p><code>.cancelled<\/code> \u2013 \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0435\u0442, \u0435\u0441\u043b\u0438 \u0437\u0430\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u043a\u0440\u0430\u043d \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0430 \u0438\u043b\u0438 \u0435\u0441\u043b\u0438 \u043f\u043e\u0437\u0432\u043e\u043d\u044f\u0442. \u041c\u043e\u0436\u043d\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043a\u0430\u043a \u0431\u043b\u043e\u043a\u00a0<code>.ended<\/code> \u0438\u043b\u0438 \u043e\u0442\u043c\u0435\u043d\u0438\u0442\u044c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435.<br \/>  <code>.failed<\/code>\u2013 \u0441\u043b\u0443\u0447\u0438\u0442\u0441\u044f, \u0435\u0441\u043b\u0438 \u0436\u0435\u0441\u0442 \u043e\u0442\u043c\u0435\u043d\u0438\u0442\u0441\u044f \u0434\u0440\u0443\u0433\u0438\u043c \u0436\u0435\u0441\u0442\u043e\u043c. \u0422\u0430\u043a, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0436\u0435\u0441\u0442 \u043f\u0435\u0440\u0435\u0442\u0430\u0441\u043a\u0438\u0432\u0430\u043d\u0438\u044f \u043c\u043e\u0436\u0435\u0442 \u043e\u0442\u043c\u0435\u043d\u044f\u0442\u044c \u0436\u0435\u0441\u0442 \u0442\u0430\u043f\u0430.<br \/>  <code>.possible<\/code> \u2013\u00a0\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0436\u0435\u0441\u0442\u0430, \u043e\u0431\u044b\u0447\u043d\u043e \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043e\u0441\u043e\u0431\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b.<\/p>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0430\u043d\u0435\u043b\u044c \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0442\u044c \u0438 \u0441\u0432\u0430\u0439\u043f\u043e\u043c, \u043d\u043e \u0441\u043b\u043e\u043c\u0430\u043b\u0430\u0441\u044c \u043a\u043d\u043e\u043f\u043a\u0430 <code>dismiss<\/code>. \u0422\u0430\u043a \u0441\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0432 <code>TransitionDriver<\/code> \u0435\u0441\u0442\u044c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <code>wantsInteractiveStart<\/code>, \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043e\u043d\u043e <code>true<\/code>. \u0414\u043b\u044f \u0441\u0432\u0430\u0439\u043f\u0430 \u044d\u0442\u043e \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e, \u043d\u043e \u044d\u0442\u043e \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u0442 \u043e\u0431\u044b\u0447\u043d\u044b\u0439 <code>dismiss<\/code>. <\/p>\n<p>  <\/p>\n<p>\u0420\u0430\u0437\u0432\u0435\u0434\u0451\u043c \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0436\u0435\u0441\u0442\u0430. \u0415\u0441\u043b\u0438 \u0436\u0435\u0441\u0442 \u043d\u0430\u0447\u0430\u043b\u0441\u044f, \u0442\u043e \u044d\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0435 \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u0435, \u0430 \u0435\u0441\u043b\u0438 \u043d\u0435 \u043d\u0430\u0447\u0438\u043d\u0430\u043b\u0441\u044f, \u0442\u043e \u043e\u0431\u044b\u0447\u043d\u043e\u0435:<\/p>\n<p>  <\/p>\n<pre><code class=\"swift\">override var wantsInteractiveStart: Bool {     get {         let gestureIsActive = panRecognizer?.state == .began         return gestureIsActive     }      set { } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043c\u043e\u0436\u0435\u0442 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0441\u043a\u0440\u044b\u0442\u0438\u0435\u043c:<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/p3\/qr\/go\/p3qrgoadrowvn22livjfkr200h0.gif\"><\/p>\n<p>  <\/p>\n<h3 id=\"preryvaem-tranzishen\">\u041f\u0440\u0435\u0440\u044b\u0432\u0430\u0435\u043c \u0442\u0440\u0430\u043d\u0437\u0438\u0448\u0435\u043d<\/h3>\n<p>  <\/p>\n<p>\u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u043c\u044b \u043d\u0430\u0447\u0430\u043b\u0438 \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0442\u044c \u043d\u0430\u0448\u0443 \u043a\u0430\u0440\u0442\u043e\u0447\u043a\u0443, \u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0443\u043c\u0430\u043b\u0438 \u0438 \u0445\u043e\u0442\u0438\u043c \u0432\u0435\u0440\u043d\u0443\u0442\u044c.\u00a0\u042d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e: \u0432 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438\u00a0<code>.began<\/code> \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c <code>pause()<\/code> \u0434\u043b\u044f \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438. <\/p>\n<p>  <\/p>\n<p>\u041d\u043e \u043d\u0443\u0436\u043d\u043e \u0440\u0430\u0437\u0432\u0435\u0441\u0442\u0438 \u0434\u0432\u0430 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u044f: <\/p>\n<p>  <\/p>\n<ul>\n<li>\u043a\u043e\u0433\u0434\u0430 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u0441\u043a\u0440\u044b\u0442\u0438\u0435 \u043e\u0442 \u0436\u0435\u0441\u0442\u0430;<\/li>\n<li>\u043a\u043e\u0433\u0434\u0430 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u0435\u043c \u0442\u0435\u043a\u0443\u0449\u0438\u0439. <\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u0441\u043b\u0435 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c <code>percentComplete:<\/code> \u0435\u0441\u043b\u0438 \u043e\u043d \u0440\u0430\u0432\u0435\u043d 0, \u0442\u043e \u043c\u044b \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u0435 \u043a\u0430\u0440\u0442\u043e\u0447\u043a\u0438 \u0432\u0440\u0443\u0447\u043d\u0443\u044e, \u043f\u043b\u044e\u0441 \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u0437\u0432\u0430\u0442\u044c <code>dismiss<\/code>. \u0415\u0441\u043b\u0438 \u043d\u0435 \u0440\u0430\u0432\u0435\u043d 0, \u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442 \u0441\u043a\u0440\u044b\u0442\u0438\u0435 \u0443\u0436\u0435 \u043d\u0430\u0447\u0430\u043b\u043e\u0441\u044c, \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044e:<\/p>\n<p>  <\/p>\n<pre><code class=\"swift\">case .began:     pause() \/\/ Pause allows to detect percentComplete     if percentComplete == 0 {         presentedController?.dismiss(animated: true)     }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041d\u0430\u0436\u0438\u043c\u0430\u044e \u043a\u043d\u043e\u043f\u043a\u0443 \u0438 \u0441\u0440\u0430\u0437\u0443 \u0441\u0432\u0430\u0439\u043f\u0430\u044e \u0432\u0435\u0440\u0445, \u0447\u0442\u043e\u0431\u044b \u043e\u0442\u043c\u0435\u043d\u0438\u0442\u044c \u0441\u043a\u0440\u044b\u0442\u0438\u0435:<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/sf\/n2\/zk\/sfn2zkd2zfg8kp5dl-oyczlmh8c.gif\"><\/p>\n<p>  <\/p>\n<h4 id=\"preryvaem-pokaz-kontrollera\">\u041f\u0440\u0435\u0440\u044b\u0432\u0430\u0435\u043c \u043f\u043e\u043a\u0430\u0437 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430<\/h4>\n<p>  <\/p>\n<p>\u041e\u0431\u0440\u0430\u0442\u043d\u0430\u044f \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f: \u043a\u0430\u0440\u0442\u043e\u0447\u043a\u0430 \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c\u0441\u044f, \u043d\u043e \u043d\u0430\u043c \u044d\u0442\u043e \u043d\u0435 \u043d\u0443\u0436\u043d\u043e. \u041c\u044b \u043b\u043e\u0432\u0438\u043c \u0435\u0451 \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u0432\u0430\u0439\u043f\u043e\u043c \u0432\u043d\u0438\u0437 \u043e\u0431\u0440\u0430\u0442\u043d\u043e.\u00a0\u041f\u0440\u0435\u0440\u0432\u0430\u0442\u044c \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044e \u043f\u043e\u043a\u0430\u0437\u0430 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 \u043c\u043e\u0436\u043d\u043e \u0442\u0435\u043c\u0438 \u0436\u0435 \u0448\u0430\u0433\u0430\u043c\u0438:<\/p>\n<p>  <\/p>\n<ol>\n<li>\u0412\u0435\u0440\u043d\u0443\u0442\u044c \u0434\u0440\u0430\u0439\u0432\u0435\u0440 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 \u0438\u043d\u0442\u0435\u0440\u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u043f\u043e\u043a\u0430\u0437\u0430:<br \/> \n<pre><code class=\"swift\">func interactionControllerForPresentation(using animator: UIViewControllerAnimatedTransitioning) -&gt; UIViewControllerInteractiveTransitioning? { return driver }<\/code><\/pre>\n<\/li>\n<li>\n<p>\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0436\u0435\u0441\u0442, \u043d\u043e \u0441 \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u0438 \u0437\u0430\u0432\u0435\u0440\u0448\u0451\u043d\u043d\u043e\u0441\u0442\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"swift\">private func handlePresentation(recognizer r: UIPanGestureRecognizer) { switch r.state { case .began:     pause()  case .changed:     let increment = -r.incrementToBottom(maxTranslation: maxTranslation)     update(percentComplete + increment)  case .ended, .cancelled:     if r.isProjectedToDownHalf(maxTranslation: maxTranslation) {         cancel()     } else {         finish()     }  case .failed:     cancel()  default:     break } }<\/code><\/pre>\n<p>  <\/li>\n<\/ol>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043f\u043e\u043a\u0430\u0437\u0430 \u0438 \u0441\u043a\u0440\u044b\u0442\u0438\u044f, \u044f \u0432\u0432\u0451\u043b enum \u0441 \u0442\u0435\u043a\u0443\u0449\u0438\u043c \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"swift\">enum TransitionDirection {     case present, dismiss }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0421\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0432 <code>TransitionDriver<\/code> \u0438 \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u0442\u043e, \u043a\u0430\u043a\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0436\u0435\u0441\u0442\u0430 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d:<\/p>\n<p>  <\/p>\n<pre><code class=\"swift\">var direction: TransitionDirection = .present      @objc private func handle(recognizer r: UIPanGestureRecognizer) {     switch direction {         case .present:             handlePresentation(recognizer: r)         case .dismiss:             handleDismiss(recognizer: r)         }     }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u0430\u043a \u0436\u0435 \u043e\u043d\u043e \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 <code>wantsInteractiveStart<\/code>. \u041a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u043c\u044b \u043d\u0435 \u043f\u043b\u0430\u043d\u0438\u0440\u0443\u0435\u043c \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0436\u0435\u0441\u0442\u043e\u043c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c <code>false<\/code> \u0434\u043b\u044f <code>.present<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"swift\">override var wantsInteractiveStart: Bool {     get {         switch direction {             case .present:                 return false             case .dismiss:                 let gestureIsActive = panRecognizer?.state == .began                 return gestureIsActive         }     }      set { } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041d\u0443 \u0438 \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0441\u043c\u0435\u043d\u0438\u0442\u044c \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0436\u0435\u0441\u0442\u0430, \u043a\u043e\u0433\u0434\u0430 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u0431\u044b\u043b \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u043e\u043a\u0430\u0437\u0430\u043d. \u041b\u0443\u0447\u0448\u0435\u0435 \u043c\u0435\u0441\u0442\u043e \u2013\u00a0\u0432 <code>PresentationController<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"swift\">override func presentationTransitionDidEnd(_ completed: Bool) { super.presentationTransitionDidEnd(completed)      if completed {         driver.direction = .dismiss     } }<\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0410 \u043c\u043e\u0436\u043d\u043e \u0431\u0435\u0437 enum?<\/b><\/p>\n<div class=\"spoiler_text\">\n<p>\u041a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0431\u044b, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043e\u043f\u0438\u0440\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 <code>isBeingPresented<\/code> \u0438 <code>isBeingDismissed<\/code>. \u041d\u043e \u043e\u043d\u0438 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441, \u0430 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u044b \u0435\u0449\u0451 \u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f: \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u0438\u043d\u0442\u0435\u0440\u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u044f \u043e\u0431\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0443\u0442 <code>false<\/code>, \u0430 \u043d\u0430\u043c \u0443\u0436\u0435 \u043d\u0443\u0436\u043d\u043e \u0437\u043d\u0430\u0442\u044c, \u0447\u0442\u043e \u044d\u0442\u043e \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043a \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u044e. \u042d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0448\u0438\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u043c\u0438 \u043d\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u0438 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u0432, \u043d\u043e \u044f\u0432\u043d\u043e\u0435 \u0437\u0430\u0434\u0430\u043d\u0438\u0435 \u0447\u0435\u0440\u0435\u0437 <code>enum<\/code>, \u043a\u0430\u0436\u0435\u0442\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c.\u00a0<\/p>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0435\u0440\u0432\u0430\u0442\u044c \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044e \u043f\u043e\u043a\u0430\u0437\u0430. \u041d\u0430\u0436\u0438\u043c\u0430\u044e \u043a\u043d\u043e\u043f\u043a\u0443 \u0438 \u0441\u0440\u0430\u0437\u0443 \u0441\u0432\u0430\u0439\u043f\u0430\u044e \u0432\u043d\u0438\u0437:<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/rk\/fz\/ry\/rkfzryopydxyxmco22xuhy6jhtm.gif\"><\/p>\n<p>  <\/p>\n<h2 id=\"pokazyvat-pozhestu\">\u041f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043f\u043e\u00a0\u0436\u0435\u0441\u0442\u0443<\/h2>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0434\u0435\u043b\u0430\u0435\u0442\u0435 \u0433\u0430\u043c\u0431\u0443\u0440\u0433\u0435\u0440\u043d\u043e\u0435 \u043c\u0435\u043d\u044e \u0434\u043b\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0442\u043e, \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u0437\u0430\u0445\u043e\u0447\u0435\u0442\u0441\u044f \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043f\u043e \u0436\u0435\u0441\u0442\u0443. \u042d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u0430\u043a \u0436\u0435, \u043a\u0430\u043a \u0438\u043d\u0442\u0435\u0440\u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0435 \u0441\u043a\u0440\u044b\u0442\u0438\u0435, \u043d\u043e \u0432 \u0436\u0435\u0441\u0442\u0435 \u0432\u043c\u0435\u0441\u0442\u043e <code>dismiss<\/code> \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c <code>present<\/code>.\u00a0<br \/>  \u041d\u0430\u0447\u043d\u0451\u043c \u0441 \u043a\u043e\u043d\u0446\u0430. \u0412 <code>handlePresentation(recognizer:)<\/code> \u043f\u043e\u043a\u0430\u0436\u0435\u043c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440:<\/p>\n<p>  <\/p>\n<pre><code class=\"swift\">case .began:     pause()     if !isRunning {         presentingController?.present(presentedController!, animated: true)     }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0420\u0430\u0437\u0440\u0435\u0448\u0438\u043c \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u0438\u043d\u0442\u0435\u0440\u0430\u043a\u0442\u0438\u0432\u043d\u043e:<\/p>\n<p>  <\/p>\n<pre><code class=\"swift\">override var wantsInteractiveStart: Bool {     get {         switch direction {             case .present:                 let gestureIsActive = screenEdgePanRecognizer?.state == .began                 return gestureIsActive             case .dismiss:                 \u2026<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u043a\u043e\u0434\u0430 \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u0435\u0442 \u0441\u0441\u044b\u043b\u043e\u043a \u043d\u0430 <code>presentingController<\/code> \u0438 <code>presentedController<\/code>. \u041f\u0435\u0440\u0435\u0434\u0430\u0434\u0438\u043c \u0438\u0445 \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0436\u0435\u0441\u0442\u0430, \u0434\u043e\u0431\u0430\u0432\u0438\u043c <code>UIScreenEdgePanGestureRecognizer<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"swift\">func linkPresentationGesture(to presentedController: UIViewController, presentingController: UIViewController) {     self.presentedController = presentedController     self.presentingController = presentingController      panRecognizer = UIPanGestureRecognizer(target: self, action: #selector(handle(recognizer:)))     presentedController.view.addGestureRecognizer(panRecognizer!)      screenEdgePanRecognizer = UIScreenEdgePanGestureRecognizer(target: self, action: #selector(handlePresentation(recognizer:)))     screenEdgePanRecognizer!.edges = .bottom     presentingController.view.addGestureRecognizer(screenEdgePanRecognizer!) }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u044b \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 <code>PanelTransition<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"swift\">class PanelTransition: NSObject, UIViewControllerTransitioningDelegate {     init(presented: UIViewController, presenting: UIViewController) {         driver.linkPresentationGesture(to: presented,                                 presentingController: presenting)     }     private let driver = TransitionDriver()<\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c <code>PanelTransition<\/code>:\u00a0<\/p>\n<p>  <\/p>\n<ol>\n<li>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c <code>child<\/code> \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u0432\u043e <code>viewDidLoad<\/code>, \u0442\u0430\u043a \u043a\u0430\u043a \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u043d\u0430\u043c \u0432 \u043b\u044e\u0431\u043e\u0439 \u043c\u043e\u043c\u0435\u043d\u0442.<\/li>\n<li>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c <code>PanelTransition<\/code>. \u0412 \u0435\u0433\u043e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435 \u0436\u0435\u0441\u0442 \u043f\u0440\u0438\u0432\u044f\u0436\u0435\u0442\u0441\u044f \u043a \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0443.\u00a0<\/li>\n<li>\u041f\u0440\u043e\u0441\u0442\u0430\u0432\u0438\u043c transitioningDelegate \u0434\u043b\u044f child \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430.<\/li>\n<li>\n<p>\u0414\u043b\u044f \u0443\u0447\u0435\u0431\u043d\u044b\u0445 \u0446\u0435\u043b\u0435\u0439 \u044f \u0441\u0434\u0435\u043b\u0430\u043b \u0441\u0432\u0430\u0439\u043f \u0441\u043d\u0438\u0437\u0443, \u043d\u043e \u044d\u0442\u043e \u043a\u043e\u043d\u0444\u043b\u0438\u043a\u0442\u0443\u0435\u0442 \u0441 \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430 iPhone \u0425 \u0438 \u043a\u043e\u043d\u0442\u0440\u043e\u043b \u0446\u0435\u043d\u0442\u0440\u043e\u043c. \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>preferredScreenEdgesDeferringSystemGestures<\/code> \u043e\u0442\u043a\u043b\u044e\u0447\u0438\u043b \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0441\u0432\u0430\u0439\u043f \u0441\u043d\u0438\u0437\u0443.\u00a0<\/p>\n<p>  <\/p>\n<pre><code class=\"swift\">class ParentViewController: UIViewController {  private var child: ChildViewController! private var transition: PanelTransition!  override func viewDidLoad() {     super.viewDidLoad()      child = ChildViewController() \/\/ 1     transition = PanelTransition(presented: child, presenting: self) \/\/ 2      \/\/ Setup the child     child.modalPresentationStyle = .custom     child.transitioningDelegate = transition \/\/ 3 }  override var preferredScreenEdgesDeferringSystemGestures: UIRectEdge {     return .bottom \/\/ 4 }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u0435\u0441\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430: \u043f\u043e\u0441\u043b\u0435 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u044f \u043f\u0430\u043d\u0435\u043b\u0438 \u043e\u043d\u0430 \u043d\u0430\u0432\u0441\u0435\u0433\u0434\u0430 \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u0432 \u0441\u0442\u0430\u0442\u0443\u0441\u0435 <code>TransitionDirection.dismiss<\/code>. \u041f\u043e\u0441\u0442\u0430\u0432\u0438\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439 \u0441\u0442\u0430\u0442\u0443\u0441 \u043f\u043e\u0441\u043b\u0435 \u0441\u043a\u0440\u044b\u0442\u0438\u044f \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 \u0432 <code>PresentationController<\/code>: <\/p>\n<p>  <\/p>\n<pre><code class=\"swift\">override func dismissalTransitionDidEnd(_ completed: Bool) { super.dismissalTransitionDidEnd(completed)  if completed {     driver.direction = .present } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041a\u043e\u0434 c \u0438\u043d\u0442\u0435\u0440\u0430\u043a\u0442\u0438\u0432\u043d\u044b\u043c \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c <a href=\"https:\/\/github.com\/akaDuality\/InterruptibleTransition\/tree\/interactivePresentation\">\u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u0432\u0435\u0442\u043a\u0435<\/a>. \u0412\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/u_\/1g\/l-\/u_1gl-slqy_kwqp9tlgh41qs8uu.gif\"><\/p>\n<p>  <\/li>\n<\/ol>\n<p>  <\/p>\n<h2 id=\"zaklyuchenie\">\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>  <\/p>\n<p>\u0412 \u0438\u0442\u043e\u0433\u0435 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u0441 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u0435\u043c\u043e\u0439 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0435\u0439, \u0430 \u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c \u043d\u0430\u0434 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0438\u043c \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435. \u042d\u0442\u043e \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u044f\u0442\u043d\u0435\u0439, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044f \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u0435\u0451 \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u043c\u0435\u043d\u0438\u0442\u044c \u0438\u043b\u0438 \u0434\u0430\u0436\u0435 \u0443\u0441\u043a\u043e\u0440\u0438\u0442\u044c.<\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c <a href=\"https:\/\/github.com\/akaDuality\/InterruptibleTransition\">\u043d\u0430 github.<\/a><\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u0434\u043f\u0438\u0441\u044b\u0432\u0430\u0439\u0442\u0435\u0441\u044c <a href=\"https:\/\/telegram.im\/dodomobile\">\u043d\u0430 \u043a\u0430\u043d\u0430\u043b Dodo Pizza Mobile.<\/a><\/p>\n<\/div>\n<p>               <script class=\"js-mediator-script\">!function(e){function t(t,n){if(!(n in e)){for(var r,a=e.document,i=a.scripts,o=i.length;o--;)if(-1!==i[o].src.indexOf(t)){r=i[o];break}if(!r){r=a.createElement(\"script\"),r.type=\"text\/javascript\",r.async=!0,r.defer=!0,r.src=t,r.charset=\"UTF-8\";var d=function(){var e=a.getElementsByTagName(\"script\")[0];e.parentNode.insertBefore(r,e)};\"[object Opera]\"==e.opera?a.addEventListener?a.addEventListener(\"DOMContentLoaded\",d,!1):e.attachEvent(\"onload\",d):d()}}}t(\"\/\/mediator.mail.ru\/script\/2820404\/\",\"_mediator\")}(window);<\/script>     <br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/company\/dodopizzaio\/blog\/465073\/\"> https:\/\/habr.com\/ru\/company\/dodopizzaio\/blog\/465073\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\">\n<p>\u0412\u0430\u0441 \u0442\u043e\u0436\u0435 \u0431\u0435\u0441\u044f\u0442 \u0432\u0441\u043f\u043b\u044b\u0432\u0430\u044e\u0449\u0438\u0435 \u043e\u043a\u043d\u0430 \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445? \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u043f\u043e\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u0438\u043d\u0442\u0435\u0440\u0430\u043a\u0442\u0438\u0432\u043d\u043e \u0441\u043a\u0440\u044b\u0432\u0430\u0442\u044c \u0438 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0432\u0441\u043f\u043b\u044b\u0432\u0430\u044e\u0449\u0438\u0435 \u043e\u043a\u043d\u0430, \u0434\u0435\u043b\u0430\u0442\u044c \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044e \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u0435\u043c\u043e\u0439 \u0438 \u043d\u0435 \u0431\u0435\u0441\u0438\u0442\u044c \u0441\u0432\u043e\u0438\u0445 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432.<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/dm\/no\/2f\/dmno2fidzesnqjrc1wozmragwsc.png\"><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-293998","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/293998","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=293998"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/293998\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=293998"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=293998"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=293998"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}