{"id":339431,"date":"2022-10-08T09:00:17","date_gmt":"2022-10-08T09:00:17","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=339431"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=339431","title":{"rendered":"<span>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0439 \u0434\u043b\u044f \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u0438 \u0432 iOS<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/a48\/483\/cb6\/a48483cb6e949b741eaf79125eabf594.jpg\" width=\"1280\" height=\"720\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a48\/483\/cb6\/a48483cb6e949b741eaf79125eabf594.jpg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442! \u042f \u0445\u043e\u0447\u0443 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u0441\u044f \u0441\u0432\u043e\u0438\u043c \u043e\u043f\u044b\u0442\u043e\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0445 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u043e\u0432 \u043c\u0435\u0436\u0434\u0443 \u044d\u043a\u0440\u0430\u043d\u0430\u043c\u0438 \u0432 iOS. \u041d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u0442\u0435\u043c\u0430 \u044d\u0442\u0430 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u0430\u044f, \u0438 \u043e\u0447\u0435\u043d\u044c \u043c\u043d\u043e\u0433\u0438\u0435 \u0434\u0438\u0437\u0430\u0439\u043d\u0435\u0440\u044b \u0445\u043e\u0442\u044f\u0442 \u043f\u0440\u0438\u0432\u043d\u0435\u0441\u0442\u0438 \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430 \u043a\u0430\u043a\u0443\u044e-\u0442\u043e \u0441\u0432\u043e\u044e \u0438\u0437\u044e\u043c\u0438\u043d\u043a\u0443 (\u0437\u0430\u0442\u0435\u043c\u043d\u0435\u043d\u0438\u0435, \u043f\u0430\u0440\u0430\u043b\u043b\u0430\u043a\u0441 \u0438 \u0442. \u043f.), \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u044d\u0442\u0438\u0445 \u0432\u0435\u0449\u0435\u0439 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u0430. \u042f \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u044e \u0440\u0430\u0437\u043b\u043e\u0436\u0438\u0442\u044c \u0432\u0441\u0435 \u043f\u043e \u043f\u043e\u043b\u043e\u0447\u043a\u0430\u043c. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043d\u0435 \u043e\u0441\u043e\u0431\u043e \u0433\u0438\u0431\u043a\u043e\u0435, \u043d\u043e \u0437\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e\u0435 \u0434\u043b\u044f \u043c\u043d\u043e\u0433\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432. \u0417\u0430\u0442\u0435\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u043e\u0435 \u0438 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u0443\u0435\u043c\u043e\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0430\u043c\u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u0435.<\/p>\n<p>\u0418\u0442\u0430\u043a, \u043f\u043e\u0433\u043d\u0430\u043b\u0438!<\/p>\n<p>\u0420\u0435\u0447\u044c \u043f\u043e\u0439\u0434\u0435\u0442 \u043e \u0432\u0441\u0435\u043c \u0437\u043d\u0430\u043a\u043e\u043c\u044b\u0445 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430\u0445 \u043c\u0435\u0436\u0434\u0443 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430\u043c\u0438 \u0432\u043d\u0443\u0442\u0440\u0438\u00a0 UINavigationController. \u0413\u043e\u0440\u0430\u0437\u0434\u043e \u0443\u0434\u043e\u0431\u043d\u0435\u0435 \u0438 \u043f\u0440\u0438\u044f\u0442\u043d\u0435\u0435 \u0441 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438\u043c\u0435\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u043e\u0432\u0435\u0440\u0448\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u0432\u0430\u0439\u043f\u043e\u0432. \u042d\u0442\u0443 \u0437\u0430\u0434\u0430\u0447\u0443 \u043c\u044b \u0438 \u0431\u0443\u0434\u0435\u043c \u0440\u0435\u0448\u0430\u0442\u044c \u0432 \u0441\u0442\u0430\u0442\u044c\u0435.<\/p>\n<h3>InteractivePopGestureRecognizer<\/h3>\n<p>\u0417\u0430\u0434\u0430\u0447\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u0432\u0430\u0439\u043f\u0430 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>interactivePopGestureRecognizer<\/code>. \u0420\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0447\u0440\u0435\u0437\u0432\u044b\u0447\u0430\u0439\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e:<\/p>\n<pre><code class=\"swift\">navigationController.interactivePopGestureRecognizer?.delegate = self navigationController.interactivePopGestureRecognizer?.isEnabled = true<\/code><\/pre>\n<p>\u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u0432\u0430\u0439\u043f\u0430 \u0441\u043b\u0435\u0432\u0430 \u043d\u0430\u043f\u0440\u0430\u0432\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u0432 \u0441\u0442\u044d\u043a\u0435. \u041d\u0430\u0447\u0438\u043d\u0430\u0442\u044c\u0441\u044f \u0441\u0432\u0430\u0439\u043f \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u0443\u0434\u0435\u0442 \u0441 \u043b\u0435\u0432\u043e\u0439 \u043a\u0440\u043e\u043c\u043a\u0438 \u044d\u043a\u0440\u0430\u043d\u0430.<\/p>\n<p>\u0412 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u044d\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0445\u0432\u0430\u0442\u0430\u0435\u0442. \u041d\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0447\u0430\u0441\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u043c\u0435\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c \u043d\u0430\u0434 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0435\u0439, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043d\u0430\u0434 \u0442\u0440\u0438\u0433\u0433\u0435\u0440\u043e\u043c \u0441\u0442\u0430\u0440\u0442\u0430 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438 &#8212; \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, \u0435\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u0441\u0432\u0430\u0439\u043f\u0430\u0442\u044c \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 \u044d\u043a\u0440\u0430\u043d\u0430, \u0430 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u043b\u0435\u0432\u043e\u0433\u043e \u043a\u0440\u0430\u044f.<\/p>\n<h3>UIViewControllerAnimatedTransitioning<\/h3>\n<p>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u043e\u0441\u043d\u043e\u0432\u0430\u043d \u043d\u0430 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0435 <code>UIViewControllerAnimatedTransitioning<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u043c \u043c\u0435\u0442\u043e\u0434\u0435 \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u0430 \u043d\u0430\u0448\u0435\u043c\u0443 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0443 <code>UINavigationController<\/code>. \u041e\u0431\u044a\u0435\u043a\u0442, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0449\u0438\u0439 \u044d\u0442\u043e\u0442 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b, \u0431\u0443\u0434\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0443\u044e \u043d\u0430\u043c \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0430 \u0434\u043b\u044f \u0430\u043d\u0438\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0442\u0430 \u043d\u0430 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u044d\u043a\u0440\u0430\u043d (pop). \u0412 \u043e\u0431\u0449\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0438 \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430 \u043d\u0430 \u043d\u043e\u0432\u044b\u0439 \u044d\u043a\u0440\u0430\u043d (push), \u043d\u043e \u043b\u0443\u0447\u0448\u0435 \u043f\u043e\u043a\u0430 \u0441\u043e\u0441\u0440\u0435\u0434\u043e\u0442\u043e\u0447\u0438\u0442\u044c\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u043e\u0434\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0443\u0441\u043b\u043e\u0436\u043d\u044f\u0442\u044c \u043a\u043e\u0434.<\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0438 \u043e\u0431\u044a\u0435\u043a\u0442, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0449\u0438\u0439 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b <code>UIViewControllerInteractiveTransitioning<\/code>. \u0414\u0430\u043d\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0435\u0439 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0436\u0435\u0441\u0442\u043e\u0432.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a\u0430 <code>UINavigationController<\/code>, \u043d\u0430\u0437\u043e\u0432\u0435\u043c \u0435\u0433\u043e <code>BackSwipeNavigationController<\/code>. \u042d\u0442\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u043d\u0435 \u0442\u043e, \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435, \u043d\u043e \u043c\u043d\u0435 \u0443\u0434\u043e\u0431\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0438\u043c\u0435\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u044b\u0435 <code>UINavigationController<\/code>, \u0442\u0430\u043a \u0438 \u0441 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u043e\u0439 \u043b\u043e\u0433\u0438\u043a\u043e\u0439.<\/p>\n<p>\u041f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u0444\u0430\u0439\u043b\u0430:<\/p>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"swift\">import UIKit  class BackSwipeNavigationController: UINavigationController {     lazy var navigationData: BackSwipeNavigationData = {         let data = BackSwipeNavigationData()         return data     }()      lazy var backSwipeManager: BackSwipeNavManager = {         let manager = BackSwipeNavManager(data: self.navigationData, navController: self)         return manager     }()      lazy var panGestureRecognizer: UIPanGestureRecognizer = {         UIPanGestureRecognizer(target: backSwipeManager,                                action: #selector(BackSwipeNavManager.handlePanGesture(_:)))     }()          init() {         super.init(nibName: nil, bundle: nil)         configure()     }      override init(nibName: String?, bundle: Bundle?) {         super.init(nibName: nibName, bundle: bundle)         configure()     }      override init(rootViewController: UIViewController) {         super.init(rootViewController: rootViewController)         configure()     }      func configure() {         delegate = backSwipeManager         panGestureRecognizer.isEnabled = true         view.addGestureRecognizer(panGestureRecognizer)     }          override func pushViewController(_ contoller: UIViewController, animated: Bool) {         navigationData.duringPushAnimation = true         super.pushViewController(contoller, animated: animated)     }      required init?(coder aDecoder: NSCoder) {         fatalError(\"init(coder:) has not been implemented\")     } } <\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0417\u0434\u0435\u0441\u044c \u043c\u044b \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u043c\u0435\u0442\u043e\u0434 pushViewController, \u0447\u0442\u043e\u0431\u044b \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u043c\u043e\u043c\u0435\u043d\u0442 \u043d\u0430\u0447\u0430\u043b\u0430 push-\u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u043f\u043e\u043a\u0430 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c.<\/p>\n<pre><code class=\"swift\">override func pushViewController(_ contoller: UIViewController, animated: Bool) {     navigationData.duringPushAnimation = true     super.pushViewController(contoller, animated: animated) }<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0432 \u043d\u0430\u0448\u0435\u043c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0435 \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u0432\u0430 \u043d\u043e\u0432\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 <code>BackSwipeNavigationData<\/code> \u0438 <code>BackSwipeNavManager<\/code>. \u041f\u0435\u0440\u0432\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043d\u0430\u043c \u0434\u0430\u043d\u043d\u044b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0437\u0430\u0434\u0430\u0447\u0438 \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0442\u044c. \u0412\u0442\u043e\u0440\u043e\u0439 \u0431\u0443\u0434\u0435\u0442 \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u043e\u043c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 \u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0443 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0436\u0435\u0441\u0442\u0430\u043c\u0438.<\/p>\n<pre><code class=\"swift\">lazy var navigationData: BackSwipeNavigationData = {     let data = BackSwipeNavigationData()     return data }()  lazy var backSwipeManager: BackSwipeNavManager = {     let manager = BackSwipeNavManager(data: self.navigationData, navController: self)     return manager }()<\/code><\/pre>\n<p>\u0412 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0435 \u0442\u0430\u043a\u0436\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c <code>UIPanGestureRecognizer<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043b\u043e\u0432\u0438\u0442\u044c \u0436\u0435\u0441\u0442\u044b, \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u044b \u043f\u043e\u0440\u0443\u0447\u0430\u0435\u043c <code>BackSwipeNavManager<\/code><strong>.<\/strong><\/p>\n<pre><code class=\"swift\">lazy var panGestureRecognizer: UIPanGestureRecognizer = {   UIPanGestureRecognizer(target: backSwipeManager,                          action: #selector(BackSwipeNavManager.handlePanGesture(_:))) }()<\/code><\/pre>\n<p>\u041f\u0440\u0438\u0432\u0435\u0434\u0435\u043c \u043a\u043e\u0434 <code>BackSwipeNavigationData<\/code>:<\/p>\n<pre><code class=\"swift\">class BackSwipeNavigationData {     var duringPushAnimation: Bool = false     var duringPopAnimation: Bool = false     var percentDrivenInteractiveTransition: UIPercentDrivenInteractiveTransition! }<\/code><\/pre>\n<p>\u0424\u043b\u0430\u0433\u0438 <code>duringPushAnimation<\/code> \u0438 <code>duringPopAnimation<\/code> \u0445\u0440\u0430\u043d\u044f\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0442\u0438\u043f\u0435 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438. \u041f\u043e\u0447\u0435\u043c\u0443-\u0442\u043e \u043c\u043d\u0435 \u0431\u044b\u043b\u043e \u043f\u0440\u043e\u0449\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0431\u0443\u043b\u0435\u0432\u0441\u043a\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435, \u0445\u043e\u0442\u044f \u043e\u0447\u0435\u043d\u044c \u0434\u0430\u0436\u0435 \u043f\u0440\u043e\u0441\u0438\u0442\u0441\u044f enum. \u041d\u0443 \u043d\u0435 \u0441\u0443\u0442\u044c \ud83d\ude42\u00a0<\/p>\n<p>\u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f <code>percentDrivenInteractiveTransition<\/code> \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0448\u0438\u043c \u0440\u044b\u0447\u0430\u0433\u043e\u043c \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0435\u0439. \u0418\u043c\u0435\u043d\u043d\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043d\u0435\u0435 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0442\u044c \u043c\u0430\u0433\u0438\u044e, \u0437\u0430\u0434\u0430\u0432\u0430\u044f \u043c\u043e\u043c\u0435\u043d\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u0435\u043c \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044e, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0442\u044c \u0437\u0430\u043f\u0443\u0441\u043a \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438 \u0441 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0444\u0440\u0435\u0439\u043c\u0430 \u0432\u043f\u0435\u0440\u0435\u0434 \u0438\u043b\u0438 \u043d\u0430\u0437\u0430\u0434.<\/p>\n<p>\u041f\u0440\u0435\u0436\u0434\u0435, \u0447\u0435\u043c \u043c\u044b \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 <code>BackSwipeNavManager<\/code>, \u044f \u0445\u043e\u0447\u0443 \u0441\u0445\u0435\u043c\u0430\u0442\u0438\u0447\u043d\u043e \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0432\u0441\u0435\u0445 \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u043e\u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/16c\/434\/b2b\/16c434b2b16cf5e7726b649de525dedd.png\" width=\"1575\" height=\"872\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/16c\/434\/b2b\/16c434b2b16cf5e7726b649de525dedd.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041f\u043e \u044d\u0442\u043e\u0439 \u0441\u0445\u0435\u043c\u0435 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0442\u0435\u043f\u0435\u0440\u044c \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0432 \u0434\u0432\u0443\u0445 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u0430\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u044f &#8212; <code>BackSwipeNavManager<\/code> \u0438 <code>BackSwipeAnimatedTransitioning<\/code>.<\/p>\n<p>\u0418\u0442\u0430\u043a, \u043d\u0430\u0448 <code>NavigationController<\/code> \u0431\u0443\u0434\u0435\u0442 \u0434\u0435\u043b\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u044e \u043e\u0441\u043d\u043e\u0432\u043d\u0443\u044e \u043b\u043e\u0433\u0438\u043a\u0443 \u0432 <code>BackSwipeNavManager<\/code><strong>, <\/strong>\u0432\u043a\u043b\u044e\u0447\u0430\u044f \u043b\u043e\u0433\u0438\u043a\u0443 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0436\u0435\u0441\u0442\u043e\u0432 \u043e\u0442 <code>PanGestureRecognizer<\/code> \u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 <code>UINavigationControllerDelegate<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u044e\u0442 \u043a\u0430\u0441\u0442\u043e\u043c\u0438\u0437\u0430\u0446\u0438\u044e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430.<\/p>\n<p><code>BackSwipeNavManager<\/code><strong> <\/strong>\u0431\u0443\u0434\u0435\u0442 \u0434\u0435\u043b\u0430\u0442\u044c \u0434\u0432\u0435 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0432\u0435\u0449\u0438:<\/p>\n<ol>\n<li>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u0443\u044e \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044e \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430, \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0437\u0430\u0439\u043c\u0435\u0442\u0441\u044f \u043a\u043b\u0430\u0441\u0441 <code>BackSwipeNavigationTransitioning<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u041a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u0443\u044e \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 <code>UIPercentDrivenInteractiveTransition<\/code><strong>, <\/strong>\u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0432 \u043b\u043e\u0433\u0438\u043a\u0443 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044f \u043a \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0436\u0435\u0441\u0442\u043e\u0432.<\/p>\n<\/li>\n<\/ol>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043c \u043f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 <code>BackSwipeNavManager<\/code>.<\/p>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"swift\">class BackSwipeNavManager: NSObject, UINavigationControllerDelegate {     var navigationData: BackSwipeNavigationData!     var navController: BackSwipeNavigationController!          init(data: BackSwipeNavigationData,                navController: BackSwipeNavigationController) {         navigationData = data         self.navController = navController     }          func navigationController(_ navigationController: UINavigationController,                               animationControllerFor operation: UINavigationController.Operation,                               from fromVC: UIViewController,                               to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? {         if navigationData.duringPushAnimation {             return nil         }          return BackSwipeAnimatedTransitioning()     }          func navigationController(_ navigationController: UINavigationController, didShow viewController: UIViewController, animated: Bool) {         navigationData.duringPushAnimation = false     }          func navigationController(_ navigationController: UINavigationController,                               interactionControllerFor animationController: UIViewControllerAnimatedTransitioning) -> UIViewControllerInteractiveTransitioning? {          if navigationData.duringPushAnimation {             return nil         }          if navController.panGestureRecognizer.state == .began {             navigationData.percentDrivenInteractiveTransition = UIPercentDrivenInteractiveTransition()             navigationData.percentDrivenInteractiveTransition.completionCurve = .easeOut         } else {             navigationData.percentDrivenInteractiveTransition = nil         }          return navigationData.percentDrivenInteractiveTransition     }          @objc func handlePanGesture(_ panGesture: UIPanGestureRecognizer) {         let percent = max(panGesture.translation(in: navController.view).x, 0) \/ navController.view.frame.width          switch panGesture.state {          case .began:             guard navController.viewControllers.count > 1 else {                 return             }              navController.delegate = self             navigationData.duringPopAnimation = true             navController.popViewController(animated: true)          case .changed:             if let percentDrivenInteractiveTransition = navigationData.percentDrivenInteractiveTransition {                 percentDrivenInteractiveTransition.update(percent)             }          case .ended:              navigationData.duringPopAnimation = false             guard let percentDrivenInteractiveTransition = navigationData.percentDrivenInteractiveTransition else { return }              let velocity = panGesture.velocity(in: navController.view).x              \/\/ Continue if drag more than 50% of screen width or velocity is higher than 1000             if percent > 0.5 || velocity > 1000 {                 percentDrivenInteractiveTransition.finish()             } else {                 percentDrivenInteractiveTransition.cancel()                 navigationData.percentDrivenInteractiveTransition = nil             }          case .cancelled,              .failed:              navigationData.duringPopAnimation = false             guard let percentDrivenInteractiveTransition = navigationData.percentDrivenInteractiveTransition else { return }              percentDrivenInteractiveTransition.cancel()             navigationData.percentDrivenInteractiveTransition = nil          default:             break         }     } } <\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435. \u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u043c\u0435\u0442\u043e\u0434\u0430:<\/p>\n<pre><code class=\"swift\">func navigationController(_ navigationController: UINavigationController,                           animationControllerFor operation: UINavigationController.Operation,                           from fromVC: UIViewController,                           to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? {     if navigationData.duringPushAnimation {         return nil     }      return BackSwipeAnimatedTransitioning() }<\/code><\/pre>\n<p>\u0422\u0443\u0442 \u043c\u044b \u0443\u0431\u0435\u0436\u0434\u0430\u0435\u043c\u0441\u044f, \u0447\u0442\u043e \u044d\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e pop-\u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044f. \u0417\u0430\u0442\u0435\u043c, \u0435\u0441\u043b\u0438 \u044d\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u043e\u043d\u0430, \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043a\u043b\u0430\u0441\u0441\u0430 <code>BackSwipeAnimatedTransitioning<\/code>. \u0412 \u044d\u0442\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0430 \u0441\u0430\u043c\u0430 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044f \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430, \u0438 \u0435\u0433\u043e \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u043e\u0437\u0434\u043d\u0435\u0435.\u00a0<\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u043c\u0435\u0442\u043e\u0434:<\/p>\n<pre><code class=\"swift\">func navigationController(_ navigationController: UINavigationController,                               interactionControllerFor animationController: UIViewControllerAnimatedTransitioning) -> UIViewControllerInteractiveTransitioning? {     if navigationData.duringPushAnimation {         return nil     }      if navController.panGestureRecognizer.state == .began {         navigationData.percentDrivenInteractiveTransition = UIPercentDrivenInteractiveTransition()         navigationData.percentDrivenInteractiveTransition.completionCurve = .easeOut     } else {         navigationData.percentDrivenInteractiveTransition = nil     }      return navigationData.percentDrivenInteractiveTransition }<\/code><\/pre>\n<p>\u0412 \u044d\u0442\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u043e\u0431\u044a\u0435\u043a\u0442 \u043a\u043b\u0430\u0441\u0441\u0430 <code>UIPercentDrivenInteractiveTransition<\/code>, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0431\u0443\u0434\u0435\u043c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044e.\u00a0<\/p>\n<p>\u0417\u0430\u0442\u0435\u043c \u0438\u0434\u0435\u0442 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/p>\n<pre><code class=\"swift\">@objc func handlePanGesture(_ panGesture: UIPanGestureRecognizer)<\/code><\/pre>\n<p>\u0412 \u043d\u0435\u0439 \u043c\u044b \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0436\u0435\u0441\u0442\u043e\u0432. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u0435\u0439\u0441\u044b \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0440\u0435\u043a\u043e\u0433\u043d\u0430\u0439\u0437\u0435\u0440\u0430:<\/p>\n<p><strong><em>began<\/em><\/strong><\/p>\n<p>\u0423\u0431\u0435\u0436\u0434\u0430\u0435\u043c\u0441\u044f, \u0447\u0442\u043e \u043d\u0430\u043c \u0435\u0441\u0442\u044c, \u043a\u0443\u0434\u0430 \u043e\u0442\u043a\u0430\u0442\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u0432 navigation-stack, \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u043e\u043c \u0441\u0435\u0431\u044f (\u043c\u0430\u043b\u043e \u043b\u0438, \u043a\u0442\u043e \u0435\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u043b \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \ud83d\ude42 ), \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0444\u043b\u0430\u0433 \u0442\u0438\u043f\u0430 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438, \u0438 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u043c \u0441\u0430\u043c pop.<\/p>\n<p><strong><em>changed<\/em><\/strong><\/p>\n<p>\u041e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u043c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0443 \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438. \u0415\u0433\u043e \u0432\u044b\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u043c \u0432 \u0441\u0430\u043c\u043e\u043c \u043d\u0430\u0447\u0430\u043b\u0435, \u0442\u0430\u043a \u043a\u0430\u043a \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043a\u0435\u0439\u0441\u0430\u0445.<\/p>\n<p><strong><em>ended<\/em><\/strong><\/p>\n<p>\u0417\u0434\u0435\u0441\u044c \u043c\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u043b\u043e\u0433\u0438\u043a\u0443, \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043e\u0442\u043e\u0440\u0432\u0430\u043b \u043f\u0430\u043b\u0435\u0446 \u043e\u0442 \u044d\u043a\u0440\u0430\u043d\u0430. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0443\u0436\u043d\u043e \u043b\u0438\u0431\u043e \u043e\u0442\u043a\u0430\u0442\u0438\u0442\u044c \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044e \u043d\u0430\u0437\u0430\u0434, \u043b\u0438\u0431\u043e \u0434\u043e\u0432\u0435\u0441\u0442\u0438 \u0435\u0435 \u0434\u043e \u043a\u043e\u043d\u0446\u0430. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043f\u0440\u043e\u0446\u0435\u043d\u0442 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438, \u043b\u0438\u0431\u043e \u043d\u0430 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c, \u0441 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0441\u0434\u0435\u043b\u0430\u043b \u0441\u0432\u0430\u0439\u043f.<\/p>\n<p><strong><em>cancelled \u0438\u043b\u0438 failed<\/em><\/strong><\/p>\n<p>\u0412 \u044d\u0442\u043e\u043c \u043a\u0435\u0439\u0441\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u043e\u0442\u043c\u0435\u043d\u044f\u0435\u043c \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044e.<\/p>\n<p>\u041e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0442\u0435\u043f\u0435\u0440\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0441\u0430\u043c\u043e\u0439 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438. \u0415\u0435 \u043c\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 <code>BackSwipeAnimatedTransitioning<\/code>.<\/p>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"swift\">class BackSwipeAnimatedTransitioning: NSObject, UIViewControllerAnimatedTransitioning {      func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval {         return 0.3     }          func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {         let containerView = transitionContext.containerView                  guard let fromVC = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.from),               let toVC = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.to) else {             return         }                  let fromView = fromVC.view         let toView = toVC.view                  let originToFrame = toView?.frame ?? CGRect.zero                  let width = containerView.frame.width                  var offsetLeft = fromView?.frame         offsetLeft?.origin.x = width                  var offscreenRight = toView?.frame         offscreenRight?.origin.x = -width \/ 3.33          toView?.frame = offscreenRight!                  fromView?.layer.shadowRadius = 5.0         fromView?.layer.shadowOpacity = 1.0         toView?.layer.opacity = 0.9          let toFrame = (fromView?.frame)!                  containerView.insertSubview(toView!, belowSubview: fromView!)                  UIView.animate(withDuration: transitionDuration(using: transitionContext), delay: 0, options: .curveLinear, animations: {             toView?.frame = toFrame             fromView?.frame = offsetLeft!              toView?.layer.opacity = 1.0             fromView?.layer.shadowOpacity = 0.1         }, completion: { _ in             toView?.layer.opacity = 1.0             toView?.layer.shadowOpacity = 0             fromView?.layer.opacity = 1.0             fromView?.layer.shadowOpacity = 0              toView?.frame = originToFrame             transitionContext.completeTransition(!transitionContext.transitionWasCancelled)         })     } }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0420\u0435\u0430\u043b\u0438\u0437\u0443\u044f \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b <code>UIViewControllerAnimatedTransitioning<\/code>, \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0432\u0430 \u043c\u0435\u0442\u043e\u0434\u0430, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0449\u0438\u0435 \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438 \u0438 \u0441\u0430\u043c\u0443 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044e.\u00a0<\/p>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438:\u00a0<\/p>\n<pre><code class=\"swift\">func animateTransition(using transitionContext: UIViewControllerContextTransitioning)<\/code><\/pre>\n<p>\u0412 \u043d\u0435\u0433\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430, \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430\u043c, \u043c\u0435\u0436\u0434\u0443 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u0445\u043e\u0434, \u0430 \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u043d\u0438\u043c\u0438 \u0438 \u043a \u0438\u0445 <code>view<\/code>. \u042d\u0442\u043e\u0433\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u043b\u044e\u0431\u0443\u044e \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044e \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430 \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0437\u0430\u0442\u0435\u043c \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u043b\u0435\u0433\u043a\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c.<\/p>\n<p>\u0412\u043e\u0442 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0438 \u0432\u0441\u0435. \u041e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0445\u043e\u0447\u0443 \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u0443\u0435\u043c\u044b\u0435 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0435 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u043e\u0432 \u0432 <code>UINavigationController<\/code>, \u043d\u043e \u0438 \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u043e\u0432 \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c <code>present<\/code> \u0438 <code>dismiss<\/code> \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u0432, \u0430 \u0434\u0430\u0436\u0435 \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u043e\u0432 \u043c\u0435\u0436\u0434\u0443 \u044d\u043a\u0440\u0430\u043d\u0430\u043c\u0438 <code>UITabBarController<\/code>.\u00a0<\/p>\n<p>\u0412\u0441\u0435\u043c \u0441\u043f\u0430\u0441\u0438\u0431\u043e! \u0423\u0434\u0430\u0447\u0438 \u0432 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0432\u0430\u0448\u0438\u0445 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0439 \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445! \ud83d\ude42\u00a0<\/p>\n<p>P.S. <a href=\"https:\/\/github.com\/Extremall\/BackSwipeNavigator\" rel=\"noopener noreferrer nofollow\">\u041a\u043e\u0434 \u0434\u0435\u043c\u043e-\u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0438\u0437 \u0441\u0442\u0430\u0442\u044c\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435 <\/a><\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><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\/post\/692180\/\"> https:\/\/habr.com\/ru\/post\/692180\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442! \u042f \u0445\u043e\u0447\u0443 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u0441\u044f \u0441\u0432\u043e\u0438\u043c \u043e\u043f\u044b\u0442\u043e\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0445 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u043e\u0432 \u043c\u0435\u0436\u0434\u0443 \u044d\u043a\u0440\u0430\u043d\u0430\u043c\u0438 \u0432 iOS. \u041d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u0442\u0435\u043c\u0430 \u044d\u0442\u0430 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u0430\u044f, \u0438 \u043e\u0447\u0435\u043d\u044c \u043c\u043d\u043e\u0433\u0438\u0435 \u0434\u0438\u0437\u0430\u0439\u043d\u0435\u0440\u044b \u0445\u043e\u0442\u044f\u0442 \u043f\u0440\u0438\u0432\u043d\u0435\u0441\u0442\u0438 \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430 \u043a\u0430\u043a\u0443\u044e-\u0442\u043e \u0441\u0432\u043e\u044e \u0438\u0437\u044e\u043c\u0438\u043d\u043a\u0443 (\u0437\u0430\u0442\u0435\u043c\u043d\u0435\u043d\u0438\u0435, \u043f\u0430\u0440\u0430\u043b\u043b\u0430\u043a\u0441 \u0438 \u0442. \u043f.), \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u044d\u0442\u0438\u0445 \u0432\u0435\u0449\u0435\u0439 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u0430. \u042f \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u044e \u0440\u0430\u0437\u043b\u043e\u0436\u0438\u0442\u044c \u0432\u0441\u0435 \u043f\u043e \u043f\u043e\u043b\u043e\u0447\u043a\u0430\u043c. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043d\u0435 \u043e\u0441\u043e\u0431\u043e \u0433\u0438\u0431\u043a\u043e\u0435, \u043d\u043e \u0437\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e\u0435 \u0434\u043b\u044f \u043c\u043d\u043e\u0433\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432. \u0417\u0430\u0442\u0435\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u043e\u0435 \u0438 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u0443\u0435\u043c\u043e\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0430\u043c\u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u0435.<\/p>\n<p>\u0418\u0442\u0430\u043a, \u043f\u043e\u0433\u043d\u0430\u043b\u0438!<\/p>\n<p>\u0420\u0435\u0447\u044c \u043f\u043e\u0439\u0434\u0435\u0442 \u043e \u0432\u0441\u0435\u043c \u0437\u043d\u0430\u043a\u043e\u043c\u044b\u0445 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430\u0445 \u043c\u0435\u0436\u0434\u0443 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430\u043c\u0438 \u0432\u043d\u0443\u0442\u0440\u0438\u00a0 UINavigationController. \u0413\u043e\u0440\u0430\u0437\u0434\u043e \u0443\u0434\u043e\u0431\u043d\u0435\u0435 \u0438 \u043f\u0440\u0438\u044f\u0442\u043d\u0435\u0435 \u0441 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438\u043c\u0435\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u043e\u0432\u0435\u0440\u0448\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u0432\u0430\u0439\u043f\u043e\u0432. \u042d\u0442\u0443 \u0437\u0430\u0434\u0430\u0447\u0443 \u043c\u044b \u0438 \u0431\u0443\u0434\u0435\u043c \u0440\u0435\u0448\u0430\u0442\u044c \u0432 \u0441\u0442\u0430\u0442\u044c\u0435.<\/p>\n<h3>InteractivePopGestureRecognizer<\/h3>\n<p>\u0417\u0430\u0434\u0430\u0447\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u0432\u0430\u0439\u043f\u0430 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>interactivePopGestureRecognizer<\/code>. \u0420\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0447\u0440\u0435\u0437\u0432\u044b\u0447\u0430\u0439\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e:<\/p>\n<pre><code class=\"swift\">navigationController.interactivePopGestureRecognizer?.delegate = self navigationController.interactivePopGestureRecognizer?.isEnabled = true<\/code><\/pre>\n<p>\u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u0432\u0430\u0439\u043f\u0430 \u0441\u043b\u0435\u0432\u0430 \u043d\u0430\u043f\u0440\u0430\u0432\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u0432 \u0441\u0442\u044d\u043a\u0435. \u041d\u0430\u0447\u0438\u043d\u0430\u0442\u044c\u0441\u044f \u0441\u0432\u0430\u0439\u043f \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u0443\u0434\u0435\u0442 \u0441 \u043b\u0435\u0432\u043e\u0439 \u043a\u0440\u043e\u043c\u043a\u0438 \u044d\u043a\u0440\u0430\u043d\u0430.<\/p>\n<p>\u0412 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u044d\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0445\u0432\u0430\u0442\u0430\u0435\u0442. \u041d\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0447\u0430\u0441\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u043c\u0435\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c \u043d\u0430\u0434 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0435\u0439, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043d\u0430\u0434 \u0442\u0440\u0438\u0433\u0433\u0435\u0440\u043e\u043c \u0441\u0442\u0430\u0440\u0442\u0430 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438 &#8212; \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, \u0435\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u0441\u0432\u0430\u0439\u043f\u0430\u0442\u044c \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 \u044d\u043a\u0440\u0430\u043d\u0430, \u0430 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u043b\u0435\u0432\u043e\u0433\u043e \u043a\u0440\u0430\u044f.<\/p>\n<h3>UIViewControllerAnimatedTransitioning<\/h3>\n<p>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u043e\u0441\u043d\u043e\u0432\u0430\u043d \u043d\u0430 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0435 <code>UIViewControllerAnimatedTransitioning<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u043c \u043c\u0435\u0442\u043e\u0434\u0435 \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u0430 \u043d\u0430\u0448\u0435\u043c\u0443 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0443 <code>UINavigationController<\/code>. \u041e\u0431\u044a\u0435\u043a\u0442, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0449\u0438\u0439 \u044d\u0442\u043e\u0442 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b, \u0431\u0443\u0434\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0443\u044e \u043d\u0430\u043c \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0430 \u0434\u043b\u044f \u0430\u043d\u0438\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0442\u0430 \u043d\u0430 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u044d\u043a\u0440\u0430\u043d (pop). \u0412 \u043e\u0431\u0449\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0438 \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430 \u043d\u0430 \u043d\u043e\u0432\u044b\u0439 \u044d\u043a\u0440\u0430\u043d (push), \u043d\u043e \u043b\u0443\u0447\u0448\u0435 \u043f\u043e\u043a\u0430 \u0441\u043e\u0441\u0440\u0435\u0434\u043e\u0442\u043e\u0447\u0438\u0442\u044c\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u043e\u0434\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0443\u0441\u043b\u043e\u0436\u043d\u044f\u0442\u044c \u043a\u043e\u0434.<\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0438 \u043e\u0431\u044a\u0435\u043a\u0442, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0449\u0438\u0439 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b <code>UIViewControllerInteractiveTransitioning<\/code>. \u0414\u0430\u043d\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0435\u0439 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0436\u0435\u0441\u0442\u043e\u0432.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a\u0430 <code>UINavigationController<\/code>, \u043d\u0430\u0437\u043e\u0432\u0435\u043c \u0435\u0433\u043e <code>BackSwipeNavigationController<\/code>. \u042d\u0442\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u043d\u0435 \u0442\u043e, \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435, \u043d\u043e \u043c\u043d\u0435 \u0443\u0434\u043e\u0431\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0438\u043c\u0435\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u044b\u0435 <code>UINavigationController<\/code>, \u0442\u0430\u043a \u0438 \u0441 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u043e\u0439 \u043b\u043e\u0433\u0438\u043a\u043e\u0439.<\/p>\n<p>\u041f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u0444\u0430\u0439\u043b\u0430:<\/p>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"swift\">import UIKit  class BackSwipeNavigationController: UINavigationController {     lazy var navigationData: BackSwipeNavigationData = {         let data = BackSwipeNavigationData()         return data     }()      lazy var backSwipeManager: BackSwipeNavManager = {         let manager = BackSwipeNavManager(data: self.navigationData, navController: self)         return manager     }()      lazy var panGestureRecognizer: UIPanGestureRecognizer = {         UIPanGestureRecognizer(target: backSwipeManager,                                action: #selector(BackSwipeNavManager.handlePanGesture(_:)))     }()          init() {         super.init(nibName: nil, bundle: nil)         configure()     }      override init(nibName: String?, bundle: Bundle?) {         super.init(nibName: nibName, bundle: bundle)         configure()     }      override init(rootViewController: UIViewController) {         super.init(rootViewController: rootViewController)         configure()     }      func configure() {         delegate = backSwipeManager         panGestureRecognizer.isEnabled = true         view.addGestureRecognizer(panGestureRecognizer)     }          override func pushViewController(_ contoller: UIViewController, animated: Bool) {         navigationData.duringPushAnimation = true         super.pushViewController(contoller, animated: animated)     }      required init?(coder aDecoder: NSCoder) {         fatalError(\"init(coder:) has not been implemented\")     } } <\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0417\u0434\u0435\u0441\u044c \u043c\u044b \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u043c\u0435\u0442\u043e\u0434 pushViewController, \u0447\u0442\u043e\u0431\u044b \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u043c\u043e\u043c\u0435\u043d\u0442 \u043d\u0430\u0447\u0430\u043b\u0430 push-\u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u043f\u043e\u043a\u0430 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c.<\/p>\n<pre><code class=\"swift\">override func pushViewController(_ contoller: UIViewController, animated: Bool) {     navigationData.duringPushAnimation = true     super.pushViewController(contoller, animated: animated) }<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0432 \u043d\u0430\u0448\u0435\u043c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0435 \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u0432\u0430 \u043d\u043e\u0432\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 <code>BackSwipeNavigationData<\/code> \u0438 <code>BackSwipeNavManager<\/code>. \u041f\u0435\u0440\u0432\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043d\u0430\u043c \u0434\u0430\u043d\u043d\u044b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0437\u0430\u0434\u0430\u0447\u0438 \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0442\u044c. \u0412\u0442\u043e\u0440\u043e\u0439 \u0431\u0443\u0434\u0435\u0442 \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u043e\u043c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 \u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0443 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0436\u0435\u0441\u0442\u0430\u043c\u0438.<\/p>\n<pre><code class=\"swift\">lazy var navigationData: BackSwipeNavigationData = {     let data = BackSwipeNavigationData()     return data }()  lazy var backSwipeManager: BackSwipeNavManager = {     let manager = BackSwipeNavManager(data: self.navigationData, navController: self)     return manager }()<\/code><\/pre>\n<p>\u0412 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0435 \u0442\u0430\u043a\u0436\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c <code>UIPanGestureRecognizer<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043b\u043e\u0432\u0438\u0442\u044c \u0436\u0435\u0441\u0442\u044b, \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u044b \u043f\u043e\u0440\u0443\u0447\u0430\u0435\u043c <code>BackSwipeNavManager<\/code><strong>.<\/strong><\/p>\n<pre><code class=\"swift\">lazy var panGestureRecognizer: UIPanGestureRecognizer = {   UIPanGestureRecognizer(target: backSwipeManager,                          action: #selector(BackSwipeNavManager.handlePanGesture(_:))) }()<\/code><\/pre>\n<p>\u041f\u0440\u0438\u0432\u0435\u0434\u0435\u043c \u043a\u043e\u0434 <code>BackSwipeNavigationData<\/code>:<\/p>\n<pre><code class=\"swift\">class BackSwipeNavigationData {     var duringPushAnimation: Bool = false     var duringPopAnimation: Bool = false     var percentDrivenInteractiveTransition: UIPercentDrivenInteractiveTransition! }<\/code><\/pre>\n<p>\u0424\u043b\u0430\u0433\u0438 <code>duringPushAnimation<\/code> \u0438 <code>duringPopAnimation<\/code> \u0445\u0440\u0430\u043d\u044f\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0442\u0438\u043f\u0435 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438. \u041f\u043e\u0447\u0435\u043c\u0443-\u0442\u043e \u043c\u043d\u0435 \u0431\u044b\u043b\u043e \u043f\u0440\u043e\u0449\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0431\u0443\u043b\u0435\u0432\u0441\u043a\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435, \u0445\u043e\u0442\u044f \u043e\u0447\u0435\u043d\u044c \u0434\u0430\u0436\u0435 \u043f\u0440\u043e\u0441\u0438\u0442\u0441\u044f enum. \u041d\u0443 \u043d\u0435 \u0441\u0443\u0442\u044c \ud83d\ude42\u00a0<\/p>\n<p>\u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f <code>percentDrivenInteractiveTransition<\/code> \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0448\u0438\u043c \u0440\u044b\u0447\u0430\u0433\u043e\u043c \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0435\u0439. \u0418\u043c\u0435\u043d\u043d\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043d\u0435\u0435 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0442\u044c \u043c\u0430\u0433\u0438\u044e, \u0437\u0430\u0434\u0430\u0432\u0430\u044f \u043c\u043e\u043c\u0435\u043d\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u0435\u043c \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044e, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0442\u044c \u0437\u0430\u043f\u0443\u0441\u043a \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438 \u0441 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0444\u0440\u0435\u0439\u043c\u0430 \u0432\u043f\u0435\u0440\u0435\u0434 \u0438\u043b\u0438 \u043d\u0430\u0437\u0430\u0434.<\/p>\n<p>\u041f\u0440\u0435\u0436\u0434\u0435, \u0447\u0435\u043c \u043c\u044b \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 <code>BackSwipeNavManager<\/code>, \u044f \u0445\u043e\u0447\u0443 \u0441\u0445\u0435\u043c\u0430\u0442\u0438\u0447\u043d\u043e \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0432\u0441\u0435\u0445 \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u043e\u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430.<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041f\u043e \u044d\u0442\u043e\u0439 \u0441\u0445\u0435\u043c\u0435 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0442\u0435\u043f\u0435\u0440\u044c \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0432 \u0434\u0432\u0443\u0445 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u0430\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u044f &#8212; <code>BackSwipeNavManager<\/code> \u0438 <code>BackSwipeAnimatedTransitioning<\/code>.<\/p>\n<p>\u0418\u0442\u0430\u043a, \u043d\u0430\u0448 <code>NavigationController<\/code> \u0431\u0443\u0434\u0435\u0442 \u0434\u0435\u043b\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u044e \u043e\u0441\u043d\u043e\u0432\u043d\u0443\u044e \u043b\u043e\u0433\u0438\u043a\u0443 \u0432 <code>BackSwipeNavManager<\/code><strong>, <\/strong>\u0432\u043a\u043b\u044e\u0447\u0430\u044f \u043b\u043e\u0433\u0438\u043a\u0443 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0436\u0435\u0441\u0442\u043e\u0432 \u043e\u0442 <code>PanGestureRecognizer<\/code> \u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 <code>UINavigationControllerDelegate<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u044e\u0442 \u043a\u0430\u0441\u0442\u043e\u043c\u0438\u0437\u0430\u0446\u0438\u044e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430.<\/p>\n<p><code>BackSwipeNavManager<\/code><strong> <\/strong>\u0431\u0443\u0434\u0435\u0442 \u0434\u0435\u043b\u0430\u0442\u044c \u0434\u0432\u0435 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0432\u0435\u0449\u0438:<\/p>\n<ol>\n<li>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u0443\u044e \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044e \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430, \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0437\u0430\u0439\u043c\u0435\u0442\u0441\u044f \u043a\u043b\u0430\u0441\u0441 <code>BackSwipeNavigationTransitioning<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u041a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u0443\u044e \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 <code>UIPercentDrivenInteractiveTransition<\/code><strong>, <\/strong>\u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0432 \u043b\u043e\u0433\u0438\u043a\u0443 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044f \u043a \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0436\u0435\u0441\u0442\u043e\u0432.<\/p>\n<\/li>\n<\/ol>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043c \u043f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 <code>BackSwipeNavManager<\/code>.<\/p>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"swift\">class BackSwipeNavManager: NSObject, UINavigationControllerDelegate {     var navigationData: BackSwipeNavigationData!     var navController: BackSwipeNavigationController!          init(data: BackSwipeNavigationData,                navController: BackSwipeNavigationController) {         navigationData = data         self.navController = navController     }          func navigationController(_ navigationController: UINavigationController,                               animationControllerFor operation: UINavigationController.Operation,                               from fromVC: UIViewController,                               to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? {         if navigationData.duringPushAnimation {             return nil         }          return BackSwipeAnimatedTransitioning()     }          func navigationController(_ navigationController: UINavigationController, didShow viewController: UIViewController, animated: Bool) {         navigationData.duringPushAnimation = false     }          func navigationController(_ navigationController: UINavigationController,                               interactionControllerFor animationController: UIViewControllerAnimatedTransitioning) -> UIViewControllerInteractiveTransitioning? {          if navigationData.duringPushAnimation {             return nil         }          if navController.panGestureRecognizer.state == .began {             navigationData.percentDrivenInteractiveTransition = UIPercentDrivenInteractiveTransition()             navigationData.percentDrivenInteractiveTransition.completionCurve = .easeOut         } else {             navigationData.percentDrivenInteractiveTransition = nil         }          return navigationData.percentDrivenInteractiveTransition     }          @objc func handlePanGesture(_ panGesture: UIPanGestureRecognizer) {         let percent = max(panGesture.translation(in: navController.view).x, 0) \/ navController.view.frame.width          switch panGesture.state {          case .began:             guard navController.viewControllers.count > 1 else {                 return             }              navController.delegate = self             navigationData.duringPopAnimation = true             navController.popViewController(animated: true)          case .changed:             if let percentDrivenInteractiveTransition = navigationData.percentDrivenInteractiveTransition {                 percentDrivenInteractiveTransition.update(percent)             }          case .ended:              navigationData.duringPopAnimation = false             guard let percentDrivenInteractiveTransition = navigationData.percentDrivenInteractiveTransition else { return }              let velocity = panGesture.velocity(in: navController.view).x              \/\/ Continue if drag more than 50% of screen width or velocity is higher than 1000             if percent > 0.5 || velocity > 1000 {                 percentDrivenInteractiveTransition.finish()             } else {                 percentDrivenInteractiveTransition.cancel()                 navigationData.percentDrivenInteractiveTransition = nil             }          case .cancelled,              .failed:<\/code><\/pre>\n<\/div>\n<\/details>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\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-339431","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/339431","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=339431"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/339431\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=339431"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=339431"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=339431"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}