├── .DS_Store ├── LICENSE ├── README.md └── swift3.0-侧滑完美 ├── .DS_Store ├── swift3.0-侧滑完美.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── lishengbing.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── lishengbing.xcuserdatad │ └── xcschemes │ ├── swift3.0-侧滑完美.xcscheme │ └── xcschememanagement.plist └── swift3.0-侧滑完美 ├── .DS_Store ├── Assets.xcassets └── AppIcon.appiconset │ └── Contents.json ├── Base.lproj └── Main.storyboard ├── Classes ├── .DS_Store ├── AppDelegate.swift ├── System │ ├── .DS_Store │ └── Info.plist ├── XJDragerViewController.swift ├── XJLeftViewController.swift ├── XJLeftViewController.xib ├── XJNavigationView.swift ├── XJNavigationView.xib └── XJViewController.swift ├── a1.gif └── a2.gif /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishengbing/swift3.0-XJDragerDemo/c297c6687b78eeca02c1b5156100ca1cbff1ef0c/.DS_Store -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # swift3.0-XJDragerDemo 2 | swift3.0完美侧滑 3 | https://github.com/lishengbing/swift3.0-XJDragerDemo 4 | 5 | >>>>>>oc版本链接: 6 | https://github.com/lishengbing/XJDragViewController 7 | 8 | 9 | 10 | >>![XJDmain](https://github.com/lishengbing/swift3.0-XJDragerDemo/blob/master/swift3.0-%E4%BE%A7%E6%BB%91%E5%AE%8C%E7%BE%8E/swift3.0-%E4%BE%A7%E6%BB%91%E5%AE%8C%E7%BE%8E/a1.gif) 11 | 12 | >>![XJDmain](https://github.com/lishengbing/swift3.0-XJDragerDemo/blob/master/swift3.0-%E4%BE%A7%E6%BB%91%E5%AE%8C%E7%BE%8E/swift3.0-%E4%BE%A7%E6%BB%91%E5%AE%8C%E7%BE%8E/a2.gif) 13 | 14 | 15 | 16 | >>核心父类: 17 | >>XJDragerViewController 18 | 19 | >>使用说明 20 | >>01-创建一个主控制器继承自XJDragerViewController即可 21 | 22 | >>注意点: 23 | >>01-以后在主控制器上添加自定义控件的时候,需要添加到mainView上,而不是添加到view上即可 24 | >>如:demo中XJViewController中使用同理 25 | 26 | >>02-添加左侧控制器的时候:1-加到leftView上即可 2-需要添加一行代码: 27 | //左边添加需要添加这一句: addChildViewController(leftVc) 28 | 29 | 30 | 代码演示: 31 | 32 | extension XJViewController { 33 | fileprivate func setupUI() { 34 | // 01-注意: 只要继承自我的类:XJDragerViewController,以后所有加在view上的视图控件都统统加到mainView上就可以了 35 | mainView.addSubview(navView) 36 | navView.frame = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.size.width, height: 64) 37 | navView.leftBtn.addTarget(self, action: #selector(leftClick(btn:)), for: .touchUpInside) 38 | 39 | 40 | // 02-增加左边控制器:同理:左边都是统统加在leftView上就可以了 41 | let leftVc = XJLeftViewController(kTargetRight: kTargetRight) 42 | leftView.addSubview(leftVc.view) 43 | leftVc.view.frame = CGRect(x: 0, y: 0, width: kTargetRight, height: UIScreen.main.bounds.size.height) 44 | // 03-注意:左边添加需要添加这一句 45 | addChildViewController(leftVc) 46 | } 47 | 48 | @objc fileprivate func leftClick(btn : UIButton) { 49 | leftPanClick(btn: btn) 50 | } 51 | } 52 | 53 | 54 | >> 友情链接: 55 | >>>>>>swift版本链接 56 | >> github链接: 57 | >> https://github.com/lishengbing/XJQRCodeToolDemo 58 | 59 | >> 链接: 60 | >> https://github.com/lishengbing/swift3.0-XJDragerDemo 61 | 62 | 63 | >> my.oschina.com链接: 64 | >> https://my.oschina.net/shengbingli/blog/787809 65 | 66 | 67 | -------------------------------------------------------------------------------- /swift3.0-侧滑完美/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishengbing/swift3.0-XJDragerDemo/c297c6687b78eeca02c1b5156100ca1cbff1ef0c/swift3.0-侧滑完美/.DS_Store -------------------------------------------------------------------------------- /swift3.0-侧滑完美/swift3.0-侧滑完美.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | A312772D1DE2F7490084F177 /* XJLeftViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A312772B1DE2F7490084F177 /* XJLeftViewController.swift */; }; 11 | A312772E1DE2F7490084F177 /* XJLeftViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = A312772C1DE2F7490084F177 /* XJLeftViewController.xib */; }; 12 | A31277301DE2FBD60084F177 /* a1.gif in Resources */ = {isa = PBXBuildFile; fileRef = A312772F1DE2FBD60084F177 /* a1.gif */; }; 13 | A31277321DE2FC0D0084F177 /* a2.gif in Resources */ = {isa = PBXBuildFile; fileRef = A31277311DE2FC0D0084F177 /* a2.gif */; }; 14 | A35AD3F41DE2EF8800297772 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A35AD3F21DE2EF8800297772 /* Main.storyboard */; }; 15 | A35AD3F61DE2EF8800297772 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A35AD3F51DE2EF8800297772 /* Assets.xcassets */; }; 16 | A35AD4081DE2EFDD00297772 /* XJDragerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A35AD4051DE2EFDD00297772 /* XJDragerViewController.swift */; }; 17 | A35AD40F1DE2F05B00297772 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = A35AD40E1DE2F05B00297772 /* AppDelegate.swift */; }; 18 | A35AD4111DE2F0A500297772 /* XJViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A35AD4101DE2F0A500297772 /* XJViewController.swift */; }; 19 | A35AD4151DE2F38E00297772 /* XJNavigationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A35AD4141DE2F38E00297772 /* XJNavigationView.swift */; }; 20 | A35AD4171DE2F39600297772 /* XJNavigationView.xib in Resources */ = {isa = PBXBuildFile; fileRef = A35AD4161DE2F39600297772 /* XJNavigationView.xib */; }; 21 | /* End PBXBuildFile section */ 22 | 23 | /* Begin PBXFileReference section */ 24 | A312772B1DE2F7490084F177 /* XJLeftViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = XJLeftViewController.swift; sourceTree = ""; }; 25 | A312772C1DE2F7490084F177 /* XJLeftViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = XJLeftViewController.xib; sourceTree = ""; }; 26 | A312772F1DE2FBD60084F177 /* a1.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; path = a1.gif; sourceTree = ""; }; 27 | A31277311DE2FC0D0084F177 /* a2.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; path = a2.gif; sourceTree = ""; }; 28 | A35AD3EB1DE2EF8800297772 /* swift3.0-侧滑完美.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "swift3.0-侧滑完美.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 29 | A35AD3F31DE2EF8800297772 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 30 | A35AD3F51DE2EF8800297772 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 31 | A35AD4051DE2EFDD00297772 /* XJDragerViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = XJDragerViewController.swift; sourceTree = ""; }; 32 | A35AD40B1DE2EFFD00297772 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 33 | A35AD40E1DE2F05B00297772 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 34 | A35AD4101DE2F0A500297772 /* XJViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = XJViewController.swift; sourceTree = ""; }; 35 | A35AD4141DE2F38E00297772 /* XJNavigationView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = XJNavigationView.swift; sourceTree = ""; }; 36 | A35AD4161DE2F39600297772 /* XJNavigationView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = XJNavigationView.xib; sourceTree = ""; }; 37 | /* End PBXFileReference section */ 38 | 39 | /* Begin PBXFrameworksBuildPhase section */ 40 | A35AD3E81DE2EF8800297772 /* Frameworks */ = { 41 | isa = PBXFrameworksBuildPhase; 42 | buildActionMask = 2147483647; 43 | files = ( 44 | ); 45 | runOnlyForDeploymentPostprocessing = 0; 46 | }; 47 | /* End PBXFrameworksBuildPhase section */ 48 | 49 | /* Begin PBXGroup section */ 50 | A35AD3E21DE2EF8800297772 = { 51 | isa = PBXGroup; 52 | children = ( 53 | A35AD3ED1DE2EF8800297772 /* swift3.0-侧滑完美 */, 54 | A35AD3EC1DE2EF8800297772 /* Products */, 55 | ); 56 | sourceTree = ""; 57 | }; 58 | A35AD3EC1DE2EF8800297772 /* Products */ = { 59 | isa = PBXGroup; 60 | children = ( 61 | A35AD3EB1DE2EF8800297772 /* swift3.0-侧滑完美.app */, 62 | ); 63 | name = Products; 64 | sourceTree = ""; 65 | }; 66 | A35AD3ED1DE2EF8800297772 /* swift3.0-侧滑完美 */ = { 67 | isa = PBXGroup; 68 | children = ( 69 | A31277311DE2FC0D0084F177 /* a2.gif */, 70 | A312772F1DE2FBD60084F177 /* a1.gif */, 71 | A35AD4021DE2EFDD00297772 /* Classes */, 72 | A35AD3F21DE2EF8800297772 /* Main.storyboard */, 73 | A35AD3F51DE2EF8800297772 /* Assets.xcassets */, 74 | ); 75 | path = "swift3.0-侧滑完美"; 76 | sourceTree = ""; 77 | }; 78 | A35AD4021DE2EFDD00297772 /* Classes */ = { 79 | isa = PBXGroup; 80 | children = ( 81 | A35AD4051DE2EFDD00297772 /* XJDragerViewController.swift */, 82 | A35AD40E1DE2F05B00297772 /* AppDelegate.swift */, 83 | A35AD4101DE2F0A500297772 /* XJViewController.swift */, 84 | A35AD4141DE2F38E00297772 /* XJNavigationView.swift */, 85 | A35AD4161DE2F39600297772 /* XJNavigationView.xib */, 86 | A312772B1DE2F7490084F177 /* XJLeftViewController.swift */, 87 | A312772C1DE2F7490084F177 /* XJLeftViewController.xib */, 88 | A35AD4091DE2EFFD00297772 /* System */, 89 | ); 90 | path = Classes; 91 | sourceTree = ""; 92 | }; 93 | A35AD4091DE2EFFD00297772 /* System */ = { 94 | isa = PBXGroup; 95 | children = ( 96 | A35AD40B1DE2EFFD00297772 /* Info.plist */, 97 | ); 98 | path = System; 99 | sourceTree = ""; 100 | }; 101 | /* End PBXGroup section */ 102 | 103 | /* Begin PBXNativeTarget section */ 104 | A35AD3EA1DE2EF8800297772 /* swift3.0-侧滑完美 */ = { 105 | isa = PBXNativeTarget; 106 | buildConfigurationList = A35AD3FD1DE2EF8800297772 /* Build configuration list for PBXNativeTarget "swift3.0-侧滑完美" */; 107 | buildPhases = ( 108 | A35AD3E71DE2EF8800297772 /* Sources */, 109 | A35AD3E81DE2EF8800297772 /* Frameworks */, 110 | A35AD3E91DE2EF8800297772 /* Resources */, 111 | ); 112 | buildRules = ( 113 | ); 114 | dependencies = ( 115 | ); 116 | name = "swift3.0-侧滑完美"; 117 | productName = "swift3.0-侧滑完美"; 118 | productReference = A35AD3EB1DE2EF8800297772 /* swift3.0-侧滑完美.app */; 119 | productType = "com.apple.product-type.application"; 120 | }; 121 | /* End PBXNativeTarget section */ 122 | 123 | /* Begin PBXProject section */ 124 | A35AD3E31DE2EF8800297772 /* Project object */ = { 125 | isa = PBXProject; 126 | attributes = { 127 | LastSwiftUpdateCheck = 0810; 128 | LastUpgradeCheck = 0810; 129 | ORGANIZATIONNAME = "付公司"; 130 | TargetAttributes = { 131 | A35AD3EA1DE2EF8800297772 = { 132 | CreatedOnToolsVersion = 8.1; 133 | DevelopmentTeam = Y5U92FD2EM; 134 | ProvisioningStyle = Automatic; 135 | }; 136 | }; 137 | }; 138 | buildConfigurationList = A35AD3E61DE2EF8800297772 /* Build configuration list for PBXProject "swift3.0-侧滑完美" */; 139 | compatibilityVersion = "Xcode 3.2"; 140 | developmentRegion = English; 141 | hasScannedForEncodings = 0; 142 | knownRegions = ( 143 | en, 144 | Base, 145 | ); 146 | mainGroup = A35AD3E21DE2EF8800297772; 147 | productRefGroup = A35AD3EC1DE2EF8800297772 /* Products */; 148 | projectDirPath = ""; 149 | projectRoot = ""; 150 | targets = ( 151 | A35AD3EA1DE2EF8800297772 /* swift3.0-侧滑完美 */, 152 | ); 153 | }; 154 | /* End PBXProject section */ 155 | 156 | /* Begin PBXResourcesBuildPhase section */ 157 | A35AD3E91DE2EF8800297772 /* Resources */ = { 158 | isa = PBXResourcesBuildPhase; 159 | buildActionMask = 2147483647; 160 | files = ( 161 | A31277301DE2FBD60084F177 /* a1.gif in Resources */, 162 | A35AD3F61DE2EF8800297772 /* Assets.xcassets in Resources */, 163 | A312772E1DE2F7490084F177 /* XJLeftViewController.xib in Resources */, 164 | A35AD3F41DE2EF8800297772 /* Main.storyboard in Resources */, 165 | A35AD4171DE2F39600297772 /* XJNavigationView.xib in Resources */, 166 | A31277321DE2FC0D0084F177 /* a2.gif in Resources */, 167 | ); 168 | runOnlyForDeploymentPostprocessing = 0; 169 | }; 170 | /* End PBXResourcesBuildPhase section */ 171 | 172 | /* Begin PBXSourcesBuildPhase section */ 173 | A35AD3E71DE2EF8800297772 /* Sources */ = { 174 | isa = PBXSourcesBuildPhase; 175 | buildActionMask = 2147483647; 176 | files = ( 177 | A35AD40F1DE2F05B00297772 /* AppDelegate.swift in Sources */, 178 | A312772D1DE2F7490084F177 /* XJLeftViewController.swift in Sources */, 179 | A35AD4111DE2F0A500297772 /* XJViewController.swift in Sources */, 180 | A35AD4151DE2F38E00297772 /* XJNavigationView.swift in Sources */, 181 | A35AD4081DE2EFDD00297772 /* XJDragerViewController.swift in Sources */, 182 | ); 183 | runOnlyForDeploymentPostprocessing = 0; 184 | }; 185 | /* End PBXSourcesBuildPhase section */ 186 | 187 | /* Begin PBXVariantGroup section */ 188 | A35AD3F21DE2EF8800297772 /* Main.storyboard */ = { 189 | isa = PBXVariantGroup; 190 | children = ( 191 | A35AD3F31DE2EF8800297772 /* Base */, 192 | ); 193 | name = Main.storyboard; 194 | sourceTree = ""; 195 | }; 196 | /* End PBXVariantGroup section */ 197 | 198 | /* Begin XCBuildConfiguration section */ 199 | A35AD3FB1DE2EF8800297772 /* Debug */ = { 200 | isa = XCBuildConfiguration; 201 | buildSettings = { 202 | ALWAYS_SEARCH_USER_PATHS = NO; 203 | CLANG_ANALYZER_NONNULL = YES; 204 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 205 | CLANG_CXX_LIBRARY = "libc++"; 206 | CLANG_ENABLE_MODULES = YES; 207 | CLANG_ENABLE_OBJC_ARC = YES; 208 | CLANG_WARN_BOOL_CONVERSION = YES; 209 | CLANG_WARN_CONSTANT_CONVERSION = YES; 210 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 211 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 212 | CLANG_WARN_EMPTY_BODY = YES; 213 | CLANG_WARN_ENUM_CONVERSION = YES; 214 | CLANG_WARN_INFINITE_RECURSION = YES; 215 | CLANG_WARN_INT_CONVERSION = YES; 216 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 217 | CLANG_WARN_SUSPICIOUS_MOVES = YES; 218 | CLANG_WARN_UNREACHABLE_CODE = YES; 219 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 220 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 221 | COPY_PHASE_STRIP = NO; 222 | DEBUG_INFORMATION_FORMAT = dwarf; 223 | ENABLE_STRICT_OBJC_MSGSEND = YES; 224 | ENABLE_TESTABILITY = YES; 225 | GCC_C_LANGUAGE_STANDARD = gnu99; 226 | GCC_DYNAMIC_NO_PIC = NO; 227 | GCC_NO_COMMON_BLOCKS = YES; 228 | GCC_OPTIMIZATION_LEVEL = 0; 229 | GCC_PREPROCESSOR_DEFINITIONS = ( 230 | "DEBUG=1", 231 | "$(inherited)", 232 | ); 233 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 234 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 235 | GCC_WARN_UNDECLARED_SELECTOR = YES; 236 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 237 | GCC_WARN_UNUSED_FUNCTION = YES; 238 | GCC_WARN_UNUSED_VARIABLE = YES; 239 | IPHONEOS_DEPLOYMENT_TARGET = 10.1; 240 | MTL_ENABLE_DEBUG_INFO = YES; 241 | ONLY_ACTIVE_ARCH = YES; 242 | SDKROOT = iphoneos; 243 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 244 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 245 | }; 246 | name = Debug; 247 | }; 248 | A35AD3FC1DE2EF8800297772 /* Release */ = { 249 | isa = XCBuildConfiguration; 250 | buildSettings = { 251 | ALWAYS_SEARCH_USER_PATHS = NO; 252 | CLANG_ANALYZER_NONNULL = YES; 253 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 254 | CLANG_CXX_LIBRARY = "libc++"; 255 | CLANG_ENABLE_MODULES = YES; 256 | CLANG_ENABLE_OBJC_ARC = YES; 257 | CLANG_WARN_BOOL_CONVERSION = YES; 258 | CLANG_WARN_CONSTANT_CONVERSION = YES; 259 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 260 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 261 | CLANG_WARN_EMPTY_BODY = YES; 262 | CLANG_WARN_ENUM_CONVERSION = YES; 263 | CLANG_WARN_INFINITE_RECURSION = YES; 264 | CLANG_WARN_INT_CONVERSION = YES; 265 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 266 | CLANG_WARN_SUSPICIOUS_MOVES = YES; 267 | CLANG_WARN_UNREACHABLE_CODE = YES; 268 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 269 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 270 | COPY_PHASE_STRIP = NO; 271 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 272 | ENABLE_NS_ASSERTIONS = NO; 273 | ENABLE_STRICT_OBJC_MSGSEND = YES; 274 | GCC_C_LANGUAGE_STANDARD = gnu99; 275 | GCC_NO_COMMON_BLOCKS = YES; 276 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 277 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 278 | GCC_WARN_UNDECLARED_SELECTOR = YES; 279 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 280 | GCC_WARN_UNUSED_FUNCTION = YES; 281 | GCC_WARN_UNUSED_VARIABLE = YES; 282 | IPHONEOS_DEPLOYMENT_TARGET = 10.1; 283 | MTL_ENABLE_DEBUG_INFO = NO; 284 | SDKROOT = iphoneos; 285 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 286 | VALIDATE_PRODUCT = YES; 287 | }; 288 | name = Release; 289 | }; 290 | A35AD3FE1DE2EF8800297772 /* Debug */ = { 291 | isa = XCBuildConfiguration; 292 | buildSettings = { 293 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 294 | DEVELOPMENT_TEAM = Y5U92FD2EM; 295 | INFOPLIST_FILE = "$(SRCROOT)/swift3.0-侧滑完美/Classes/System/Info.plist"; 296 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 297 | PRODUCT_BUNDLE_IDENTIFIER = "com.xj520.swift3-0-----"; 298 | PRODUCT_NAME = "$(TARGET_NAME)"; 299 | SWIFT_VERSION = 3.0; 300 | }; 301 | name = Debug; 302 | }; 303 | A35AD3FF1DE2EF8800297772 /* Release */ = { 304 | isa = XCBuildConfiguration; 305 | buildSettings = { 306 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 307 | DEVELOPMENT_TEAM = Y5U92FD2EM; 308 | INFOPLIST_FILE = "$(SRCROOT)/swift3.0-侧滑完美/Classes/System/Info.plist"; 309 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 310 | PRODUCT_BUNDLE_IDENTIFIER = "com.xj520.swift3-0-----"; 311 | PRODUCT_NAME = "$(TARGET_NAME)"; 312 | SWIFT_VERSION = 3.0; 313 | }; 314 | name = Release; 315 | }; 316 | /* End XCBuildConfiguration section */ 317 | 318 | /* Begin XCConfigurationList section */ 319 | A35AD3E61DE2EF8800297772 /* Build configuration list for PBXProject "swift3.0-侧滑完美" */ = { 320 | isa = XCConfigurationList; 321 | buildConfigurations = ( 322 | A35AD3FB1DE2EF8800297772 /* Debug */, 323 | A35AD3FC1DE2EF8800297772 /* Release */, 324 | ); 325 | defaultConfigurationIsVisible = 0; 326 | defaultConfigurationName = Release; 327 | }; 328 | A35AD3FD1DE2EF8800297772 /* Build configuration list for PBXNativeTarget "swift3.0-侧滑完美" */ = { 329 | isa = XCConfigurationList; 330 | buildConfigurations = ( 331 | A35AD3FE1DE2EF8800297772 /* Debug */, 332 | A35AD3FF1DE2EF8800297772 /* Release */, 333 | ); 334 | defaultConfigurationIsVisible = 0; 335 | defaultConfigurationName = Release; 336 | }; 337 | /* End XCConfigurationList section */ 338 | }; 339 | rootObject = A35AD3E31DE2EF8800297772 /* Project object */; 340 | } 341 | -------------------------------------------------------------------------------- /swift3.0-侧滑完美/swift3.0-侧滑完美.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /swift3.0-侧滑完美/swift3.0-侧滑完美.xcodeproj/project.xcworkspace/xcuserdata/lishengbing.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishengbing/swift3.0-XJDragerDemo/c297c6687b78eeca02c1b5156100ca1cbff1ef0c/swift3.0-侧滑完美/swift3.0-侧滑完美.xcodeproj/project.xcworkspace/xcuserdata/lishengbing.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /swift3.0-侧滑完美/swift3.0-侧滑完美.xcodeproj/xcuserdata/lishengbing.xcuserdatad/xcschemes/swift3.0-侧滑完美.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /swift3.0-侧滑完美/swift3.0-侧滑完美.xcodeproj/xcuserdata/lishengbing.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | swift3.0-侧滑完美.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | A35AD3EA1DE2EF8800297772 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /swift3.0-侧滑完美/swift3.0-侧滑完美/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishengbing/swift3.0-XJDragerDemo/c297c6687b78eeca02c1b5156100ca1cbff1ef0c/swift3.0-侧滑完美/swift3.0-侧滑完美/.DS_Store -------------------------------------------------------------------------------- /swift3.0-侧滑完美/swift3.0-侧滑完美/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /swift3.0-侧滑完美/swift3.0-侧滑完美/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /swift3.0-侧滑完美/swift3.0-侧滑完美/Classes/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishengbing/swift3.0-XJDragerDemo/c297c6687b78eeca02c1b5156100ca1cbff1ef0c/swift3.0-侧滑完美/swift3.0-侧滑完美/Classes/.DS_Store -------------------------------------------------------------------------------- /swift3.0-侧滑完美/swift3.0-侧滑完美/Classes/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // swift3.0-侧滑完美 4 | // 5 | // Created by 李胜兵 on 2016/11/21. 6 | // Copyright © 2016年 付公司. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(_ application: UIApplication) { 23 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 24 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 25 | } 26 | 27 | func applicationDidEnterBackground(_ application: UIApplication) { 28 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | } 31 | 32 | func applicationWillEnterForeground(_ application: UIApplication) { 33 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 34 | } 35 | 36 | func applicationDidBecomeActive(_ application: UIApplication) { 37 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 38 | } 39 | 40 | func applicationWillTerminate(_ application: UIApplication) { 41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42 | } 43 | 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /swift3.0-侧滑完美/swift3.0-侧滑完美/Classes/System/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishengbing/swift3.0-XJDragerDemo/c297c6687b78eeca02c1b5156100ca1cbff1ef0c/swift3.0-侧滑完美/swift3.0-侧滑完美/Classes/System/.DS_Store -------------------------------------------------------------------------------- /swift3.0-侧滑完美/swift3.0-侧滑完美/Classes/System/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /swift3.0-侧滑完美/swift3.0-侧滑完美/Classes/XJDragerViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // XJDragerViewController.swift 3 | // swift版本侧滑 4 | // 5 | // Created by 李胜兵 on 16/10/2. 6 | // Copyright © 2016年 付公司. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | private let kMargin : CGFloat = 5 11 | private let kEdgeMargin : CGFloat = 60 12 | private let animDuration : TimeInterval = 0.25 13 | 14 | enum XJDragerStyle { 15 | case defaultStyle 16 | case left 17 | case right 18 | case Same 19 | } 20 | 21 | class XJDragerViewController: UIViewController { 22 | 23 | // MARK: - 赋值对象 24 | lazy var leftView : UIView = UIView() 25 | lazy var rightView : UIView = UIView() 26 | lazy var mainView : UIView = UIView() 27 | 28 | // 值:正数越大效果越明显,负数越小越明显<左滑至右边值> 29 | var kTargetRight : CGFloat = UIScreen.main.bounds.width - kEdgeMargin { 30 | didSet { 31 | if fabs(kTargetRight) > UIScreen.main.bounds.width { 32 | kTargetRight = UIScreen.main.bounds.width - kEdgeMargin 33 | }else { 34 | kTargetRight = fabs(kTargetRight) 35 | } 36 | } 37 | } 38 | // 值:正数越大效果越明显,负数越小越明显<右滑至左边值> 39 | var kTargetLeft : CGFloat = UIScreen.main.bounds.width - kEdgeMargin { 40 | didSet { 41 | if fabs(kTargetLeft) > UIScreen.main.bounds.width { 42 | kTargetLeft = kEdgeMargin - UIScreen.main.bounds.width 43 | }else { 44 | kTargetLeft = -fabs(kTargetLeft) 45 | } 46 | } 47 | } 48 | 49 | // 默认是100,正数和负数都可以设置,效果一样 50 | var kMaxY : CGFloat = 100 51 | 52 | // MARK: - 默认是左右滑动高度都变化 53 | var kDirection : XJDragerStyle = .left 54 | 55 | // 默认是不允许右侧可以滑动:true--> 允许右侧滑动 false:不允许右侧滑动 56 | var isPanRightEable : Bool = false 57 | 58 | // 默认是从左到右 59 | static var isDirection : Bool = false 60 | 61 | 62 | 63 | override func viewDidLoad() { 64 | super.viewDidLoad() 65 | setupUI() 66 | setupGes() 67 | } 68 | } 69 | 70 | extension XJDragerViewController { 71 | fileprivate func setupUI() { 72 | view.backgroundColor = UIColor.lightGray 73 | leftView.frame = view.bounds 74 | leftView.backgroundColor = UIColor.white 75 | view.addSubview(leftView) 76 | 77 | rightView.frame = view.bounds 78 | rightView.backgroundColor = UIColor.white 79 | view.addSubview(rightView) 80 | 81 | mainView.frame = view.bounds 82 | mainView.backgroundColor = UIColor.white 83 | view.addSubview(mainView) 84 | 85 | mainView.layer.shadowColor = UIColor.black.withAlphaComponent(0.6).cgColor 86 | mainView.layer.shadowOffset = CGSize(width: -2, height: -1) 87 | mainView.layer.shadowOpacity = 0.7 88 | mainView.layer.shadowRadius = 2 89 | } 90 | } 91 | 92 | extension XJDragerViewController { 93 | fileprivate func setupGes() { 94 | let panGesture = UIPanGestureRecognizer(target: self, action: #selector(pan(panGes:))) 95 | mainView.addGestureRecognizer(panGesture) 96 | 97 | let tapgesture = UITapGestureRecognizer(target: self, action: #selector(tap(tapGes:))) 98 | mainView.addGestureRecognizer(tapgesture) 99 | } 100 | } 101 | 102 | extension XJDragerViewController { 103 | 104 | @objc fileprivate func tap(tapGes: UITapGestureRecognizer) { 105 | enableSubViews(isEable: false) 106 | UIView.animate(withDuration: animDuration) { 107 | self.mainView.frame = self.view.frame; 108 | } 109 | } 110 | 111 | @objc fileprivate func pan(panGes : UIPanGestureRecognizer) { 112 | setupFrameOffset(pagGes: panGes) 113 | } 114 | 115 | fileprivate func setupFrameOffset(pagGes : UIPanGestureRecognizer) { 116 | let tranP = pagGes.translation(in: mainView) 117 | let velocity = pagGes.velocity(in: mainView) 118 | 119 | if tranP.x > 0 { 120 | XJDragerViewController.isDirection = false 121 | }else if (tranP.x < 0) { 122 | XJDragerViewController.isDirection = true 123 | } 124 | 125 | if !isPanRightEable, tranP.x < 0 { 126 | if mainView.frame.origin.x == 0 { 127 | mainView.frame = frameWithOffsetX(offsetX: 0) 128 | }else { 129 | mainView.frame.origin.x += tranP.x 130 | if mainView.frame.origin.x <= 0 { 131 | mainView.frame.origin.x = 0 132 | } 133 | 134 | let maxOffsetY : CGFloat = changeStyleWithDirection(type: kDirection) 135 | mainView.frame.origin.y = fabs(mainView.frame.origin.x * maxOffsetY / UIScreen.main.bounds.width) 136 | mainView.frame.size.height = UIScreen.main.bounds.height - 2 * mainView.frame.origin.y 137 | 138 | } 139 | pagGes.setTranslation(CGPoint.zero, in: mainView) 140 | return 141 | } 142 | 143 | mainView.frame = frameWithOffsetX(offsetX: tranP.x) 144 | 145 | if mainView.frame.origin.x > 0 { 146 | rightView.isHidden = true 147 | mainView.layer.shadowOffset = CGSize(width: -3, height: -1) 148 | } 149 | 150 | if mainView.frame.origin.x == 0 { 151 | enableSubViews(isEable: false) 152 | }else { 153 | enableSubViews(isEable: true) 154 | } 155 | 156 | if mainView.frame.origin.x < 0 { 157 | rightView.isHidden = false 158 | mainView.layer.shadowOffset = CGSize(width: 3, height: 1) 159 | } 160 | 161 | if pagGes.state == .ended { 162 | var target : CGFloat = 0 163 | if mainView.frame.origin.x > 0 { 164 | if velocity.x >= 0 { 165 | if mainView.frame.origin.x > kMargin { 166 | target = kTargetRight 167 | } 168 | }else { 169 | enableSubViews(isEable: false) 170 | if mainView.frame.origin.x < UIScreen.main.bounds.width - kMargin { 171 | target = 0 172 | } 173 | } 174 | } 175 | 176 | if mainView.frame.origin.x < 0 { 177 | if XJDragerViewController.isDirection { 178 | if mainView.frame.maxX < UIScreen.main.bounds.width - kMargin { 179 | target = -fabs(kTargetLeft) 180 | } 181 | } 182 | } 183 | 184 | let offset : CGFloat = target - mainView.frame.origin.x 185 | UIView.animate(withDuration: animDuration, delay: 0, usingSpringWithDamping: 1.0, initialSpringVelocity: 2, options: [], animations: { 186 | self.mainView.frame = self.frameWithOffsetX(offsetX: offset) 187 | }, completion: { (_) in 188 | }) 189 | } 190 | if mainView.frame.origin.x > kTargetRight { 191 | mainView.frame.origin.x = kTargetRight 192 | } 193 | pagGes.setTranslation(CGPoint.zero, in: mainView) 194 | } 195 | 196 | fileprivate func frameWithOffsetX(offsetX : CGFloat) -> CGRect { 197 | mainView.frame.origin.x += offsetX 198 | 199 | let maxOffsetY : CGFloat = changeStyleWithDirection(type: kDirection) 200 | mainView.frame.origin.y = fabs(mainView.frame.origin.x * maxOffsetY / UIScreen.main.bounds.width) 201 | mainView.frame.size.height = UIScreen.main.bounds.height - 2 * mainView.frame.origin.y 202 | return mainView.frame 203 | } 204 | 205 | fileprivate func changeStyleWithDirection(type : XJDragerStyle) -> CGFloat { 206 | var maxOffsetY : CGFloat = kMaxY 207 | if mainView.frame.origin.x > 0 { 208 | switch type { 209 | case .left , .Same: 210 | maxOffsetY = 0 211 | default: 212 | maxOffsetY = kMaxY 213 | } 214 | } 215 | 216 | if mainView.frame.origin.x < 0 { 217 | switch type { 218 | case .right , .Same: 219 | maxOffsetY = 0 220 | default: 221 | maxOffsetY = kMaxY 222 | } 223 | } 224 | return maxOffsetY 225 | } 226 | } 227 | 228 | extension XJDragerViewController { 229 | // 外面按钮点击事件调用方法即可 230 | func leftPanClick(btn : UIButton) { 231 | enableSubViews(isEable: true) 232 | btn.isSelected = !btn.isSelected 233 | if mainView.frame.origin.x >= 0 { 234 | rightView.isHidden = true 235 | leftView.isHidden = false 236 | changeStatusWithLeft() 237 | } 238 | } 239 | 240 | fileprivate func enableSubViews(isEable : Bool) { 241 | for subView in mainView.subviews { 242 | if isEable { 243 | subView.isUserInteractionEnabled = false 244 | }else { 245 | subView.isUserInteractionEnabled = true 246 | } 247 | } 248 | } 249 | 250 | fileprivate func changeStatusWithLeft() { 251 | var offset : CGFloat = 0 252 | if mainView.frame.origin.x == 0 { 253 | offset = kTargetRight 254 | }else { 255 | offset = -fabs(kTargetLeft) 256 | } 257 | UIView.animate(withDuration: animDuration, delay: 0, usingSpringWithDamping: 0.9, initialSpringVelocity: 2, options: [], animations: { 258 | self.mainView.frame = self.frameWithOffsetX(offsetX: offset) 259 | }, completion: { (_) in 260 | }) 261 | } 262 | } 263 | 264 | 265 | 266 | 267 | 268 | -------------------------------------------------------------------------------- /swift3.0-侧滑完美/swift3.0-侧滑完美/Classes/XJLeftViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // XJLeftViewController.swift 3 | // swift3.0-侧滑完美 4 | // 5 | // Created by 李胜兵 on 2016/11/21. 6 | // Copyright © 2016年 付公司. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | private let kCollectionViewCellID = "kCollectionViewCellID" 11 | private let kEdgeMargin : CGFloat = 26 12 | private let kMiddleMargin : CGFloat = 22 13 | private let kTopMargin : CGFloat = 33.5 14 | 15 | class XJLeftViewController: UIViewController { 16 | 17 | @IBOutlet weak var collectionView: UICollectionView! 18 | fileprivate var targetRight : CGFloat = 0 19 | 20 | init(kTargetRight : CGFloat) { 21 | super.init(nibName: nil, bundle: nil) 22 | self.targetRight = kTargetRight 23 | } 24 | 25 | required init?(coder aDecoder: NSCoder) { 26 | fatalError("init(coder:) has not been implemented") 27 | } 28 | 29 | override func viewDidLoad() { 30 | super.viewDidLoad() 31 | setupUI() 32 | } 33 | 34 | } 35 | 36 | // MARK: - 设置 UI 37 | extension XJLeftViewController { 38 | fileprivate func setupUI() { 39 | collectionView.register(UICollectionViewCell.self, forCellWithReuseIdentifier: kCollectionViewCellID) 40 | collectionView.alwaysBounceVertical = true 41 | collectionView.showsVerticalScrollIndicator = false 42 | 43 | let itemW : CGFloat = (targetRight - kEdgeMargin * 2 - kMiddleMargin) / 2 44 | let layout = collectionView.collectionViewLayout as! UICollectionViewFlowLayout 45 | layout.itemSize = CGSize(width: itemW, height: itemW) 46 | layout.minimumLineSpacing = kTopMargin 47 | layout.minimumInteritemSpacing = kMiddleMargin 48 | layout.sectionInset = UIEdgeInsetsMake(kTopMargin, kEdgeMargin, kMiddleMargin, kEdgeMargin) 49 | } 50 | 51 | } 52 | 53 | extension XJLeftViewController : UICollectionViewDataSource { 54 | 55 | func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { 56 | return 16 57 | } 58 | 59 | func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { 60 | let cell = collectionView.dequeueReusableCell(withReuseIdentifier: kCollectionViewCellID, for: indexPath) 61 | cell.backgroundColor = UIColor.blue 62 | return cell 63 | 64 | } 65 | } 66 | 67 | -------------------------------------------------------------------------------- /swift3.0-侧滑完美/swift3.0-侧滑完美/Classes/XJLeftViewController.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /swift3.0-侧滑完美/swift3.0-侧滑完美/Classes/XJNavigationView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // XJNavigationView.swift 3 | // swift3.0-侧滑完美 4 | // 5 | // Created by 李胜兵 on 2016/11/21. 6 | // Copyright © 2016年 付公司. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class XJNavigationView: UIView { 12 | @IBOutlet weak var leftBtn: UIButton! 13 | @IBOutlet weak var rightBtn: UIButton! 14 | 15 | } 16 | 17 | extension XJNavigationView { 18 | class func navView() -> XJNavigationView{ 19 | return Bundle.main.loadNibNamed("XJNavigationView", owner: self, options: nil)?.first as! XJNavigationView 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /swift3.0-侧滑完美/swift3.0-侧滑完美/Classes/XJNavigationView.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 22 | 26 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /swift3.0-侧滑完美/swift3.0-侧滑完美/Classes/XJViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // XJViewController.swift 3 | // swift3.0-侧滑完美 4 | // 5 | // Created by 李胜兵 on 2016/11/21. 6 | // Copyright © 2016年 付公司. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class XJViewController: XJDragerViewController { 12 | 13 | 14 | fileprivate lazy var navView : XJNavigationView = XJNavigationView.navView() 15 | 16 | override func viewDidLoad() { 17 | super.viewDidLoad() 18 | setupUI() 19 | } 20 | 21 | override func viewWillAppear(_ animated: Bool) { 22 | super.viewWillAppear(animated) 23 | self.navigationController?.setNavigationBarHidden(true, animated: false) 24 | } 25 | 26 | override func viewWillDisappear(_ animated: Bool) { 27 | super.viewWillDisappear(animated) 28 | self.navigationController?.setNavigationBarHidden(false, animated: false) 29 | } 30 | } 31 | 32 | extension XJViewController { 33 | fileprivate func setupUI() { 34 | // 01-注意: 只要继承自我的类:XJDragerViewController,以后所有加在view上的视图控件都统统加到mainView上就可以了 35 | mainView.addSubview(navView) 36 | navView.frame = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.size.width, height: 64) 37 | navView.leftBtn.addTarget(self, action: #selector(leftClick(btn:)), for: .touchUpInside) 38 | 39 | 40 | // 02-增加左边控制器:同理:左边都是统统加在leftView上就可以了 41 | let leftVc = XJLeftViewController(kTargetRight: kTargetRight) 42 | leftView.addSubview(leftVc.view) 43 | leftVc.view.frame = CGRect(x: 0, y: 0, width: kTargetRight, height: UIScreen.main.bounds.size.height) 44 | // 03-注意:左边添加需要添加这一句 45 | addChildViewController(leftVc) 46 | } 47 | 48 | @objc fileprivate func leftClick(btn : UIButton) { 49 | leftPanClick(btn: btn) 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /swift3.0-侧滑完美/swift3.0-侧滑完美/a1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishengbing/swift3.0-XJDragerDemo/c297c6687b78eeca02c1b5156100ca1cbff1ef0c/swift3.0-侧滑完美/swift3.0-侧滑完美/a1.gif -------------------------------------------------------------------------------- /swift3.0-侧滑完美/swift3.0-侧滑完美/a2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishengbing/swift3.0-XJDragerDemo/c297c6687b78eeca02c1b5156100ca1cbff1ef0c/swift3.0-侧滑完美/swift3.0-侧滑完美/a2.gif --------------------------------------------------------------------------------