├── .gitignore ├── LICENSE ├── README.md ├── TRMultipanelViewController.podspec ├── demo ├── Podfile └── TRMultipanelViewControllerDemo │ ├── TRMultipanelViewControllerDemo.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata │ ├── TRMultipanelViewControllerDemo │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Base.lproj │ │ ├── LaunchScreen.xib │ │ └── Main.storyboard │ ├── CollectionViewCell.h │ ├── CollectionViewCell.m │ ├── CollectionViewController.h │ ├── CollectionViewController.m │ ├── Images.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Info.plist │ ├── ViewController.h │ ├── ViewController.m │ └── main.m │ └── TRMultipanelViewControllerDemoTests │ ├── Info.plist │ └── TRMultipanelViewControllerDemoTests.m ├── multipanel-demo.gif └── multipanel ├── TRMultipanelViewController.h ├── TRMultipanelViewController.m ├── TRMultipanelViewControllerSide.h ├── TRMultipanelViewControllerSide.m ├── UIView+TRMultipanel.h └── UIView+TRMultipanel.m /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | build/ 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | xcuserdata 13 | *.xccheckout 14 | *.moved-aside 15 | DerivedData 16 | *.hmap 17 | *.ipa 18 | *.xcuserstate 19 | 20 | # CocoaPods 21 | # 22 | # We recommend against adding the Pods directory to your .gitignore. However 23 | # you should judge for yourself, the pros and cons are mentioned at: 24 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 25 | # 26 | # Pods/ 27 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Vitali 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # TRMultipanelViewController 2 | 3 | iOS panel view controller with left and right side panels. When any side panel slide inside visible area central content area is resized. 4 | You can customize left, right and center views. 5 | 6 | ## Demo 7 | ![multipanel demo](https://raw.github.com/incaffeine/TRMultipanelViewController/master/multipanel-demo.gif) 8 | 9 | ## Usage 10 | There are two modes of multipanel. First mode tightly connects central view to side views by constraints. When side view change position then central view changes his frame according to constraints. This is default mode. 11 | 12 | In the second mode central view is not directly connected to sides. It has left/right constraints to superview. When any side slide on/off screen parent multipanel change appropriate constraint value on the center view. You can turn this mode by setting *connectCenterViewToSides* to *YES* 13 | 14 | Typcal initialization 15 | 16 | [self.multipanel setConnectCenterViewToSides:YES]; 17 | [self.multipanel setWidth:240 forSide:TRMultipanelSideTypeLeft]; 18 | [self.multipanel setWidth:240 forSide:TRMultipanelSideTypeRight]; 19 | 20 | [self.multipanel setCenterController:centerController]; 21 | 22 | [self.multipanel setContentController:leftController 23 | forSide:TRMultipanelSideTypeLeft]; 24 | 25 | [self.multipanel setContentController:rightController 26 | forSide:TRMultipanelSideTypeRight]; 27 | 28 | You can hide/show/toggle sides manually. For example: 29 | 30 | [self.multipanel toggleSide:TRMultipanelSideTypeRight animated:YES]; 31 | 32 | You can subscribe on show/hide notifications: 33 | 34 | TRMultipanelWillShowSideNotification 35 | TRMultipanelDidShowSideNotification 36 | TRMultipanelWillHideSideNotification 37 | TRMultipanelDidHideSideNotification 38 | 39 | ##License 40 | 41 | This project is distributed under the terms and conditions of the [MIT license](LICENSE). 42 | 43 | 44 | -------------------------------------------------------------------------------- /TRMultipanelViewController.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = 'TRMultipanelViewController' 3 | s.version = '0.3' 4 | s.platform = :ios, '6.0' 5 | s.license = { :type => 'MIT', :file => 'LICENSE' } 6 | s.summary = 'iOS view controller with center content and panels on both sides' 7 | s.homepage = 'https://github.com/incaffeine/TRMultipanelViewController' 8 | s.author = { 'Vitali Bondur' => 'bondur@gmail.com' } 9 | s.requires_arc = true 10 | s.source = { :git => 'https://github.com/incaffeine/TRMultipanelViewController.git', :branch => 'master', :tag => s.version.to_s } 11 | s.source_files = 'multipanel/*.{h,m}' 12 | s.public_header_files = 'multipanel/TRMultipanelViewController.h' 13 | end -------------------------------------------------------------------------------- /demo/Podfile: -------------------------------------------------------------------------------- 1 | platform :ios, "6.0" 2 | 3 | xcodeproj 'TRMultipanelViewControllerDemo/TRMultipanelViewControllerDemo.xcodeproj' 4 | 5 | pod 'TRMultipanelViewController', :git => 'https://github.com/incaffeine/TRMultipanelViewController.git' -------------------------------------------------------------------------------- /demo/TRMultipanelViewControllerDemo/TRMultipanelViewControllerDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 538CFF982EDF3F245F192259 /* libPods.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 55BFC96F713A5F1DAEEC09F4 /* libPods.a */; }; 11 | 64313BC91A6C05C200AFF287 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 64313BC81A6C05C200AFF287 /* main.m */; }; 12 | 64313BCC1A6C05C200AFF287 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 64313BCB1A6C05C200AFF287 /* AppDelegate.m */; }; 13 | 64313BCF1A6C05C200AFF287 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 64313BCE1A6C05C200AFF287 /* ViewController.m */; }; 14 | 64313BD21A6C05C200AFF287 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 64313BD01A6C05C200AFF287 /* Main.storyboard */; }; 15 | 64313BD41A6C05C200AFF287 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 64313BD31A6C05C200AFF287 /* Images.xcassets */; }; 16 | 64313BD71A6C05C200AFF287 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 64313BD51A6C05C200AFF287 /* LaunchScreen.xib */; }; 17 | 64313BE31A6C05C200AFF287 /* TRMultipanelViewControllerDemoTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 64313BE21A6C05C200AFF287 /* TRMultipanelViewControllerDemoTests.m */; }; 18 | 64313BEE1A6C103400AFF287 /* CollectionViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 64313BED1A6C103400AFF287 /* CollectionViewController.m */; }; 19 | 64313BF11A6C11E700AFF287 /* CollectionViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 64313BF01A6C11E700AFF287 /* CollectionViewCell.m */; }; 20 | 64313BF31A6C155900AFF287 /* AssetsLibrary.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 64313BF21A6C155900AFF287 /* AssetsLibrary.framework */; }; 21 | /* End PBXBuildFile section */ 22 | 23 | /* Begin PBXContainerItemProxy section */ 24 | 64313BDD1A6C05C200AFF287 /* PBXContainerItemProxy */ = { 25 | isa = PBXContainerItemProxy; 26 | containerPortal = 64313BBB1A6C05C200AFF287 /* Project object */; 27 | proxyType = 1; 28 | remoteGlobalIDString = 64313BC21A6C05C200AFF287; 29 | remoteInfo = TRMultipanelViewControllerDemo; 30 | }; 31 | /* End PBXContainerItemProxy section */ 32 | 33 | /* Begin PBXFileReference section */ 34 | 34E27FD10CD674FC304B4EA3 /* Pods.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.debug.xcconfig; path = "../Pods/Target Support Files/Pods/Pods.debug.xcconfig"; sourceTree = ""; }; 35 | 55BFC96F713A5F1DAEEC09F4 /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; }; 36 | 596277415AD12829F1985F41 /* Pods.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.release.xcconfig; path = "../Pods/Target Support Files/Pods/Pods.release.xcconfig"; sourceTree = ""; }; 37 | 64313BC31A6C05C200AFF287 /* TRMultipanelViewControllerDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = TRMultipanelViewControllerDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 38 | 64313BC71A6C05C200AFF287 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 39 | 64313BC81A6C05C200AFF287 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 40 | 64313BCA1A6C05C200AFF287 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 41 | 64313BCB1A6C05C200AFF287 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 42 | 64313BCD1A6C05C200AFF287 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 43 | 64313BCE1A6C05C200AFF287 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 44 | 64313BD11A6C05C200AFF287 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 45 | 64313BD31A6C05C200AFF287 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 46 | 64313BD61A6C05C200AFF287 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 47 | 64313BDC1A6C05C200AFF287 /* TRMultipanelViewControllerDemoTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = TRMultipanelViewControllerDemoTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 48 | 64313BE11A6C05C200AFF287 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 49 | 64313BE21A6C05C200AFF287 /* TRMultipanelViewControllerDemoTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TRMultipanelViewControllerDemoTests.m; sourceTree = ""; }; 50 | 64313BEC1A6C103400AFF287 /* CollectionViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CollectionViewController.h; sourceTree = ""; }; 51 | 64313BED1A6C103400AFF287 /* CollectionViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CollectionViewController.m; sourceTree = ""; }; 52 | 64313BEF1A6C11E700AFF287 /* CollectionViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CollectionViewCell.h; sourceTree = ""; }; 53 | 64313BF01A6C11E700AFF287 /* CollectionViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CollectionViewCell.m; sourceTree = ""; }; 54 | 64313BF21A6C155900AFF287 /* AssetsLibrary.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AssetsLibrary.framework; path = System/Library/Frameworks/AssetsLibrary.framework; sourceTree = SDKROOT; }; 55 | /* End PBXFileReference section */ 56 | 57 | /* Begin PBXFrameworksBuildPhase section */ 58 | 64313BC01A6C05C200AFF287 /* Frameworks */ = { 59 | isa = PBXFrameworksBuildPhase; 60 | buildActionMask = 2147483647; 61 | files = ( 62 | 64313BF31A6C155900AFF287 /* AssetsLibrary.framework in Frameworks */, 63 | 538CFF982EDF3F245F192259 /* libPods.a in Frameworks */, 64 | ); 65 | runOnlyForDeploymentPostprocessing = 0; 66 | }; 67 | 64313BD91A6C05C200AFF287 /* Frameworks */ = { 68 | isa = PBXFrameworksBuildPhase; 69 | buildActionMask = 2147483647; 70 | files = ( 71 | ); 72 | runOnlyForDeploymentPostprocessing = 0; 73 | }; 74 | /* End PBXFrameworksBuildPhase section */ 75 | 76 | /* Begin PBXGroup section */ 77 | 4B6F5795D06B809FD1ED17C5 /* Frameworks */ = { 78 | isa = PBXGroup; 79 | children = ( 80 | 64313BF21A6C155900AFF287 /* AssetsLibrary.framework */, 81 | 55BFC96F713A5F1DAEEC09F4 /* libPods.a */, 82 | ); 83 | name = Frameworks; 84 | sourceTree = ""; 85 | }; 86 | 64313BBA1A6C05C200AFF287 = { 87 | isa = PBXGroup; 88 | children = ( 89 | 64313BC51A6C05C200AFF287 /* TRMultipanelViewControllerDemo */, 90 | 64313BDF1A6C05C200AFF287 /* TRMultipanelViewControllerDemoTests */, 91 | 64313BC41A6C05C200AFF287 /* Products */, 92 | 8DEE13C570AC03377A98230C /* Pods */, 93 | 4B6F5795D06B809FD1ED17C5 /* Frameworks */, 94 | ); 95 | sourceTree = ""; 96 | }; 97 | 64313BC41A6C05C200AFF287 /* Products */ = { 98 | isa = PBXGroup; 99 | children = ( 100 | 64313BC31A6C05C200AFF287 /* TRMultipanelViewControllerDemo.app */, 101 | 64313BDC1A6C05C200AFF287 /* TRMultipanelViewControllerDemoTests.xctest */, 102 | ); 103 | name = Products; 104 | sourceTree = ""; 105 | }; 106 | 64313BC51A6C05C200AFF287 /* TRMultipanelViewControllerDemo */ = { 107 | isa = PBXGroup; 108 | children = ( 109 | 64313BCA1A6C05C200AFF287 /* AppDelegate.h */, 110 | 64313BCB1A6C05C200AFF287 /* AppDelegate.m */, 111 | 64313BCD1A6C05C200AFF287 /* ViewController.h */, 112 | 64313BCE1A6C05C200AFF287 /* ViewController.m */, 113 | 64313BEC1A6C103400AFF287 /* CollectionViewController.h */, 114 | 64313BED1A6C103400AFF287 /* CollectionViewController.m */, 115 | 64313BEF1A6C11E700AFF287 /* CollectionViewCell.h */, 116 | 64313BF01A6C11E700AFF287 /* CollectionViewCell.m */, 117 | 64313BD01A6C05C200AFF287 /* Main.storyboard */, 118 | 64313BD31A6C05C200AFF287 /* Images.xcassets */, 119 | 64313BD51A6C05C200AFF287 /* LaunchScreen.xib */, 120 | 64313BC61A6C05C200AFF287 /* Supporting Files */, 121 | ); 122 | path = TRMultipanelViewControllerDemo; 123 | sourceTree = ""; 124 | }; 125 | 64313BC61A6C05C200AFF287 /* Supporting Files */ = { 126 | isa = PBXGroup; 127 | children = ( 128 | 64313BC71A6C05C200AFF287 /* Info.plist */, 129 | 64313BC81A6C05C200AFF287 /* main.m */, 130 | ); 131 | name = "Supporting Files"; 132 | sourceTree = ""; 133 | }; 134 | 64313BDF1A6C05C200AFF287 /* TRMultipanelViewControllerDemoTests */ = { 135 | isa = PBXGroup; 136 | children = ( 137 | 64313BE21A6C05C200AFF287 /* TRMultipanelViewControllerDemoTests.m */, 138 | 64313BE01A6C05C200AFF287 /* Supporting Files */, 139 | ); 140 | path = TRMultipanelViewControllerDemoTests; 141 | sourceTree = ""; 142 | }; 143 | 64313BE01A6C05C200AFF287 /* Supporting Files */ = { 144 | isa = PBXGroup; 145 | children = ( 146 | 64313BE11A6C05C200AFF287 /* Info.plist */, 147 | ); 148 | name = "Supporting Files"; 149 | sourceTree = ""; 150 | }; 151 | 8DEE13C570AC03377A98230C /* Pods */ = { 152 | isa = PBXGroup; 153 | children = ( 154 | 34E27FD10CD674FC304B4EA3 /* Pods.debug.xcconfig */, 155 | 596277415AD12829F1985F41 /* Pods.release.xcconfig */, 156 | ); 157 | name = Pods; 158 | sourceTree = ""; 159 | }; 160 | /* End PBXGroup section */ 161 | 162 | /* Begin PBXNativeTarget section */ 163 | 64313BC21A6C05C200AFF287 /* TRMultipanelViewControllerDemo */ = { 164 | isa = PBXNativeTarget; 165 | buildConfigurationList = 64313BE61A6C05C200AFF287 /* Build configuration list for PBXNativeTarget "TRMultipanelViewControllerDemo" */; 166 | buildPhases = ( 167 | CAFF425C07EF21EA90D58539 /* Check Pods Manifest.lock */, 168 | 64313BBF1A6C05C200AFF287 /* Sources */, 169 | 64313BC01A6C05C200AFF287 /* Frameworks */, 170 | 64313BC11A6C05C200AFF287 /* Resources */, 171 | 7928C61A1F6B10A17678E38B /* Copy Pods Resources */, 172 | ); 173 | buildRules = ( 174 | ); 175 | dependencies = ( 176 | ); 177 | name = TRMultipanelViewControllerDemo; 178 | productName = TRMultipanelViewControllerDemo; 179 | productReference = 64313BC31A6C05C200AFF287 /* TRMultipanelViewControllerDemo.app */; 180 | productType = "com.apple.product-type.application"; 181 | }; 182 | 64313BDB1A6C05C200AFF287 /* TRMultipanelViewControllerDemoTests */ = { 183 | isa = PBXNativeTarget; 184 | buildConfigurationList = 64313BE91A6C05C200AFF287 /* Build configuration list for PBXNativeTarget "TRMultipanelViewControllerDemoTests" */; 185 | buildPhases = ( 186 | 64313BD81A6C05C200AFF287 /* Sources */, 187 | 64313BD91A6C05C200AFF287 /* Frameworks */, 188 | 64313BDA1A6C05C200AFF287 /* Resources */, 189 | ); 190 | buildRules = ( 191 | ); 192 | dependencies = ( 193 | 64313BDE1A6C05C200AFF287 /* PBXTargetDependency */, 194 | ); 195 | name = TRMultipanelViewControllerDemoTests; 196 | productName = TRMultipanelViewControllerDemoTests; 197 | productReference = 64313BDC1A6C05C200AFF287 /* TRMultipanelViewControllerDemoTests.xctest */; 198 | productType = "com.apple.product-type.bundle.unit-test"; 199 | }; 200 | /* End PBXNativeTarget section */ 201 | 202 | /* Begin PBXProject section */ 203 | 64313BBB1A6C05C200AFF287 /* Project object */ = { 204 | isa = PBXProject; 205 | attributes = { 206 | LastUpgradeCheck = 0610; 207 | ORGANIZATIONNAME = bondur; 208 | TargetAttributes = { 209 | 64313BC21A6C05C200AFF287 = { 210 | CreatedOnToolsVersion = 6.1.1; 211 | }; 212 | 64313BDB1A6C05C200AFF287 = { 213 | CreatedOnToolsVersion = 6.1.1; 214 | TestTargetID = 64313BC21A6C05C200AFF287; 215 | }; 216 | }; 217 | }; 218 | buildConfigurationList = 64313BBE1A6C05C200AFF287 /* Build configuration list for PBXProject "TRMultipanelViewControllerDemo" */; 219 | compatibilityVersion = "Xcode 3.2"; 220 | developmentRegion = English; 221 | hasScannedForEncodings = 0; 222 | knownRegions = ( 223 | en, 224 | Base, 225 | ); 226 | mainGroup = 64313BBA1A6C05C200AFF287; 227 | productRefGroup = 64313BC41A6C05C200AFF287 /* Products */; 228 | projectDirPath = ""; 229 | projectRoot = ""; 230 | targets = ( 231 | 64313BC21A6C05C200AFF287 /* TRMultipanelViewControllerDemo */, 232 | 64313BDB1A6C05C200AFF287 /* TRMultipanelViewControllerDemoTests */, 233 | ); 234 | }; 235 | /* End PBXProject section */ 236 | 237 | /* Begin PBXResourcesBuildPhase section */ 238 | 64313BC11A6C05C200AFF287 /* Resources */ = { 239 | isa = PBXResourcesBuildPhase; 240 | buildActionMask = 2147483647; 241 | files = ( 242 | 64313BD21A6C05C200AFF287 /* Main.storyboard in Resources */, 243 | 64313BD71A6C05C200AFF287 /* LaunchScreen.xib in Resources */, 244 | 64313BD41A6C05C200AFF287 /* Images.xcassets in Resources */, 245 | ); 246 | runOnlyForDeploymentPostprocessing = 0; 247 | }; 248 | 64313BDA1A6C05C200AFF287 /* Resources */ = { 249 | isa = PBXResourcesBuildPhase; 250 | buildActionMask = 2147483647; 251 | files = ( 252 | ); 253 | runOnlyForDeploymentPostprocessing = 0; 254 | }; 255 | /* End PBXResourcesBuildPhase section */ 256 | 257 | /* Begin PBXShellScriptBuildPhase section */ 258 | 7928C61A1F6B10A17678E38B /* Copy Pods Resources */ = { 259 | isa = PBXShellScriptBuildPhase; 260 | buildActionMask = 2147483647; 261 | files = ( 262 | ); 263 | inputPaths = ( 264 | ); 265 | name = "Copy Pods Resources"; 266 | outputPaths = ( 267 | ); 268 | runOnlyForDeploymentPostprocessing = 0; 269 | shellPath = /bin/sh; 270 | shellScript = "\"${SRCROOT}/../Pods/Target Support Files/Pods/Pods-resources.sh\"\n"; 271 | showEnvVarsInLog = 0; 272 | }; 273 | CAFF425C07EF21EA90D58539 /* Check Pods Manifest.lock */ = { 274 | isa = PBXShellScriptBuildPhase; 275 | buildActionMask = 2147483647; 276 | files = ( 277 | ); 278 | inputPaths = ( 279 | ); 280 | name = "Check Pods Manifest.lock"; 281 | outputPaths = ( 282 | ); 283 | runOnlyForDeploymentPostprocessing = 0; 284 | shellPath = /bin/sh; 285 | shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; 286 | showEnvVarsInLog = 0; 287 | }; 288 | /* End PBXShellScriptBuildPhase section */ 289 | 290 | /* Begin PBXSourcesBuildPhase section */ 291 | 64313BBF1A6C05C200AFF287 /* Sources */ = { 292 | isa = PBXSourcesBuildPhase; 293 | buildActionMask = 2147483647; 294 | files = ( 295 | 64313BEE1A6C103400AFF287 /* CollectionViewController.m in Sources */, 296 | 64313BF11A6C11E700AFF287 /* CollectionViewCell.m in Sources */, 297 | 64313BCF1A6C05C200AFF287 /* ViewController.m in Sources */, 298 | 64313BCC1A6C05C200AFF287 /* AppDelegate.m in Sources */, 299 | 64313BC91A6C05C200AFF287 /* main.m in Sources */, 300 | ); 301 | runOnlyForDeploymentPostprocessing = 0; 302 | }; 303 | 64313BD81A6C05C200AFF287 /* Sources */ = { 304 | isa = PBXSourcesBuildPhase; 305 | buildActionMask = 2147483647; 306 | files = ( 307 | 64313BE31A6C05C200AFF287 /* TRMultipanelViewControllerDemoTests.m in Sources */, 308 | ); 309 | runOnlyForDeploymentPostprocessing = 0; 310 | }; 311 | /* End PBXSourcesBuildPhase section */ 312 | 313 | /* Begin PBXTargetDependency section */ 314 | 64313BDE1A6C05C200AFF287 /* PBXTargetDependency */ = { 315 | isa = PBXTargetDependency; 316 | target = 64313BC21A6C05C200AFF287 /* TRMultipanelViewControllerDemo */; 317 | targetProxy = 64313BDD1A6C05C200AFF287 /* PBXContainerItemProxy */; 318 | }; 319 | /* End PBXTargetDependency section */ 320 | 321 | /* Begin PBXVariantGroup section */ 322 | 64313BD01A6C05C200AFF287 /* Main.storyboard */ = { 323 | isa = PBXVariantGroup; 324 | children = ( 325 | 64313BD11A6C05C200AFF287 /* Base */, 326 | ); 327 | name = Main.storyboard; 328 | sourceTree = ""; 329 | }; 330 | 64313BD51A6C05C200AFF287 /* LaunchScreen.xib */ = { 331 | isa = PBXVariantGroup; 332 | children = ( 333 | 64313BD61A6C05C200AFF287 /* Base */, 334 | ); 335 | name = LaunchScreen.xib; 336 | sourceTree = ""; 337 | }; 338 | /* End PBXVariantGroup section */ 339 | 340 | /* Begin XCBuildConfiguration section */ 341 | 64313BE41A6C05C200AFF287 /* Debug */ = { 342 | isa = XCBuildConfiguration; 343 | buildSettings = { 344 | ALWAYS_SEARCH_USER_PATHS = NO; 345 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 346 | CLANG_CXX_LIBRARY = "libc++"; 347 | CLANG_ENABLE_MODULES = YES; 348 | CLANG_ENABLE_OBJC_ARC = YES; 349 | CLANG_WARN_BOOL_CONVERSION = YES; 350 | CLANG_WARN_CONSTANT_CONVERSION = YES; 351 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 352 | CLANG_WARN_EMPTY_BODY = YES; 353 | CLANG_WARN_ENUM_CONVERSION = YES; 354 | CLANG_WARN_INT_CONVERSION = YES; 355 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 356 | CLANG_WARN_UNREACHABLE_CODE = YES; 357 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 358 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 359 | COPY_PHASE_STRIP = NO; 360 | ENABLE_STRICT_OBJC_MSGSEND = YES; 361 | GCC_C_LANGUAGE_STANDARD = gnu99; 362 | GCC_DYNAMIC_NO_PIC = NO; 363 | GCC_OPTIMIZATION_LEVEL = 0; 364 | GCC_PREPROCESSOR_DEFINITIONS = ( 365 | "DEBUG=1", 366 | "$(inherited)", 367 | ); 368 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 369 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 370 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 371 | GCC_WARN_UNDECLARED_SELECTOR = YES; 372 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 373 | GCC_WARN_UNUSED_FUNCTION = YES; 374 | GCC_WARN_UNUSED_VARIABLE = YES; 375 | IPHONEOS_DEPLOYMENT_TARGET = 8.1; 376 | MTL_ENABLE_DEBUG_INFO = YES; 377 | ONLY_ACTIVE_ARCH = YES; 378 | SDKROOT = iphoneos; 379 | TARGETED_DEVICE_FAMILY = 2; 380 | }; 381 | name = Debug; 382 | }; 383 | 64313BE51A6C05C200AFF287 /* Release */ = { 384 | isa = XCBuildConfiguration; 385 | buildSettings = { 386 | ALWAYS_SEARCH_USER_PATHS = NO; 387 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 388 | CLANG_CXX_LIBRARY = "libc++"; 389 | CLANG_ENABLE_MODULES = YES; 390 | CLANG_ENABLE_OBJC_ARC = YES; 391 | CLANG_WARN_BOOL_CONVERSION = YES; 392 | CLANG_WARN_CONSTANT_CONVERSION = YES; 393 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 394 | CLANG_WARN_EMPTY_BODY = YES; 395 | CLANG_WARN_ENUM_CONVERSION = YES; 396 | CLANG_WARN_INT_CONVERSION = YES; 397 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 398 | CLANG_WARN_UNREACHABLE_CODE = YES; 399 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 400 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 401 | COPY_PHASE_STRIP = YES; 402 | ENABLE_NS_ASSERTIONS = NO; 403 | ENABLE_STRICT_OBJC_MSGSEND = YES; 404 | GCC_C_LANGUAGE_STANDARD = gnu99; 405 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 406 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 407 | GCC_WARN_UNDECLARED_SELECTOR = YES; 408 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 409 | GCC_WARN_UNUSED_FUNCTION = YES; 410 | GCC_WARN_UNUSED_VARIABLE = YES; 411 | IPHONEOS_DEPLOYMENT_TARGET = 8.1; 412 | MTL_ENABLE_DEBUG_INFO = NO; 413 | SDKROOT = iphoneos; 414 | TARGETED_DEVICE_FAMILY = 2; 415 | VALIDATE_PRODUCT = YES; 416 | }; 417 | name = Release; 418 | }; 419 | 64313BE71A6C05C200AFF287 /* Debug */ = { 420 | isa = XCBuildConfiguration; 421 | baseConfigurationReference = 34E27FD10CD674FC304B4EA3 /* Pods.debug.xcconfig */; 422 | buildSettings = { 423 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 424 | INFOPLIST_FILE = TRMultipanelViewControllerDemo/Info.plist; 425 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 426 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 427 | PRODUCT_NAME = "$(TARGET_NAME)"; 428 | }; 429 | name = Debug; 430 | }; 431 | 64313BE81A6C05C200AFF287 /* Release */ = { 432 | isa = XCBuildConfiguration; 433 | baseConfigurationReference = 596277415AD12829F1985F41 /* Pods.release.xcconfig */; 434 | buildSettings = { 435 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 436 | INFOPLIST_FILE = TRMultipanelViewControllerDemo/Info.plist; 437 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 438 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 439 | PRODUCT_NAME = "$(TARGET_NAME)"; 440 | }; 441 | name = Release; 442 | }; 443 | 64313BEA1A6C05C200AFF287 /* Debug */ = { 444 | isa = XCBuildConfiguration; 445 | buildSettings = { 446 | BUNDLE_LOADER = "$(TEST_HOST)"; 447 | FRAMEWORK_SEARCH_PATHS = ( 448 | "$(SDKROOT)/Developer/Library/Frameworks", 449 | "$(inherited)", 450 | ); 451 | GCC_PREPROCESSOR_DEFINITIONS = ( 452 | "DEBUG=1", 453 | "$(inherited)", 454 | ); 455 | INFOPLIST_FILE = TRMultipanelViewControllerDemoTests/Info.plist; 456 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 457 | PRODUCT_NAME = "$(TARGET_NAME)"; 458 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/TRMultipanelViewControllerDemo.app/TRMultipanelViewControllerDemo"; 459 | }; 460 | name = Debug; 461 | }; 462 | 64313BEB1A6C05C200AFF287 /* Release */ = { 463 | isa = XCBuildConfiguration; 464 | buildSettings = { 465 | BUNDLE_LOADER = "$(TEST_HOST)"; 466 | FRAMEWORK_SEARCH_PATHS = ( 467 | "$(SDKROOT)/Developer/Library/Frameworks", 468 | "$(inherited)", 469 | ); 470 | INFOPLIST_FILE = TRMultipanelViewControllerDemoTests/Info.plist; 471 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 472 | PRODUCT_NAME = "$(TARGET_NAME)"; 473 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/TRMultipanelViewControllerDemo.app/TRMultipanelViewControllerDemo"; 474 | }; 475 | name = Release; 476 | }; 477 | /* End XCBuildConfiguration section */ 478 | 479 | /* Begin XCConfigurationList section */ 480 | 64313BBE1A6C05C200AFF287 /* Build configuration list for PBXProject "TRMultipanelViewControllerDemo" */ = { 481 | isa = XCConfigurationList; 482 | buildConfigurations = ( 483 | 64313BE41A6C05C200AFF287 /* Debug */, 484 | 64313BE51A6C05C200AFF287 /* Release */, 485 | ); 486 | defaultConfigurationIsVisible = 0; 487 | defaultConfigurationName = Release; 488 | }; 489 | 64313BE61A6C05C200AFF287 /* Build configuration list for PBXNativeTarget "TRMultipanelViewControllerDemo" */ = { 490 | isa = XCConfigurationList; 491 | buildConfigurations = ( 492 | 64313BE71A6C05C200AFF287 /* Debug */, 493 | 64313BE81A6C05C200AFF287 /* Release */, 494 | ); 495 | defaultConfigurationIsVisible = 0; 496 | defaultConfigurationName = Release; 497 | }; 498 | 64313BE91A6C05C200AFF287 /* Build configuration list for PBXNativeTarget "TRMultipanelViewControllerDemoTests" */ = { 499 | isa = XCConfigurationList; 500 | buildConfigurations = ( 501 | 64313BEA1A6C05C200AFF287 /* Debug */, 502 | 64313BEB1A6C05C200AFF287 /* Release */, 503 | ); 504 | defaultConfigurationIsVisible = 0; 505 | defaultConfigurationName = Release; 506 | }; 507 | /* End XCConfigurationList section */ 508 | }; 509 | rootObject = 64313BBB1A6C05C200AFF287 /* Project object */; 510 | } 511 | -------------------------------------------------------------------------------- /demo/TRMultipanelViewControllerDemo/TRMultipanelViewControllerDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /demo/TRMultipanelViewControllerDemo/TRMultipanelViewControllerDemo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // Created by Vitali Bondur on 1/18/15. 4 | // 5 | 6 | #import 7 | 8 | @interface AppDelegate : UIResponder 9 | 10 | @property (strong, nonatomic) UIWindow *window; 11 | 12 | 13 | @end 14 | 15 | -------------------------------------------------------------------------------- /demo/TRMultipanelViewControllerDemo/TRMultipanelViewControllerDemo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // Created by Vitali Bondur on 1/18/15. 4 | // 5 | 6 | #import "AppDelegate.h" 7 | 8 | @interface AppDelegate () 9 | 10 | @end 11 | 12 | @implementation AppDelegate 13 | 14 | 15 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 16 | // Override point for customization after application launch. 17 | return YES; 18 | } 19 | 20 | - (void)applicationWillResignActive:(UIApplication *)application { 21 | // 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. 22 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 23 | } 24 | 25 | - (void)applicationDidEnterBackground:(UIApplication *)application { 26 | // 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. 27 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 28 | } 29 | 30 | - (void)applicationWillEnterForeground:(UIApplication *)application { 31 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 32 | } 33 | 34 | - (void)applicationDidBecomeActive:(UIApplication *)application { 35 | // 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. 36 | } 37 | 38 | - (void)applicationWillTerminate:(UIApplication *)application { 39 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 40 | } 41 | 42 | @end 43 | -------------------------------------------------------------------------------- /demo/TRMultipanelViewControllerDemo/TRMultipanelViewControllerDemo/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /demo/TRMultipanelViewControllerDemo/TRMultipanelViewControllerDemo/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 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | -------------------------------------------------------------------------------- /demo/TRMultipanelViewControllerDemo/TRMultipanelViewControllerDemo/CollectionViewCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // CollectionViewCell.h 3 | // Created by Vitali Bondur on 1/18/15. 4 | // 5 | 6 | #import 7 | 8 | @interface CollectionViewCell : UICollectionViewCell 9 | 10 | @property (weak, nonatomic) IBOutlet UIImageView *imageView; 11 | 12 | @end 13 | -------------------------------------------------------------------------------- /demo/TRMultipanelViewControllerDemo/TRMultipanelViewControllerDemo/CollectionViewCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // CollectionViewCell.m 3 | // Created by Vitali Bondur on 1/18/15. 4 | // 5 | 6 | #import "CollectionViewCell.h" 7 | 8 | @implementation CollectionViewCell 9 | 10 | @end 11 | -------------------------------------------------------------------------------- /demo/TRMultipanelViewControllerDemo/TRMultipanelViewControllerDemo/CollectionViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // CollectionViewController.h 3 | // Created by Vitali Bondur on 1/18/15. 4 | // 5 | 6 | #import 7 | 8 | @interface CollectionViewController : UICollectionViewController 9 | 10 | @property (assign, nonatomic) BOOL updateAfterResize; 11 | 12 | @end 13 | -------------------------------------------------------------------------------- /demo/TRMultipanelViewControllerDemo/TRMultipanelViewControllerDemo/CollectionViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // CollectionViewController.m 3 | // Created by Vitali Bondur on 1/18/15. 4 | // 5 | 6 | #import "CollectionViewController.h" 7 | 8 | #import "CollectionViewCell.h" 9 | 10 | #import 11 | #import 12 | 13 | static CGFloat ContainerPadding = 10; 14 | static CGFloat ImagesPerLine = 2; 15 | static CGFloat CellMargin = 10; 16 | 17 | @interface CollectionViewController () 18 | 19 | @property (strong, nonatomic) ALAssetsLibrary* library; 20 | @property (strong, nonatomic) NSMutableArray* assets; 21 | 22 | @end 23 | 24 | @implementation CollectionViewController 25 | 26 | - (NSMutableArray*)assets { 27 | if (!_assets) { 28 | _assets = [NSMutableArray new]; 29 | } 30 | return _assets; 31 | } 32 | 33 | - (ALAssetsLibrary*)library { 34 | if (!_library) { 35 | _library = [[ALAssetsLibrary alloc] init]; 36 | } 37 | return _library; 38 | } 39 | 40 | - (void)viewDidLoad { 41 | [super viewDidLoad]; 42 | 43 | [self collectImages]; 44 | 45 | [[NSNotificationCenter defaultCenter] addObserver:self 46 | selector:@selector(onToggleMultipanelSide:) 47 | name:TRMultipanelDidShowSideNotification 48 | object:nil]; 49 | 50 | if (self.updateAfterResize) 51 | [[NSNotificationCenter defaultCenter] addObserver:self 52 | selector:@selector(onToggleMultipanelSide:) 53 | name:TRMultipanelWillHideSideNotification 54 | object:nil]; 55 | else 56 | [[NSNotificationCenter defaultCenter] addObserver:self 57 | selector:@selector(onToggleMultipanelSide:) 58 | name:TRMultipanelDidHideSideNotification 59 | object:nil]; 60 | 61 | 62 | [self updateLayout]; 63 | } 64 | 65 | - (void)viewDidAppear:(BOOL)animated { 66 | [super viewDidAppear:animated]; 67 | 68 | self.collectionView.contentInset = UIEdgeInsetsZero; 69 | } 70 | 71 | #pragma mark 72 | 73 | - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView { 74 | return 1; 75 | } 76 | 77 | - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { 78 | return self.assets.count; 79 | } 80 | 81 | - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { 82 | CollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([CollectionViewCell class]) forIndexPath:indexPath]; 83 | 84 | ALAsset* asset = [self.assets objectAtIndex:indexPath.row]; 85 | 86 | cell.imageView.image = [UIImage imageWithCGImage:[asset thumbnail]]; 87 | 88 | return cell; 89 | } 90 | 91 | - (void)collectImages { 92 | 93 | [self.library enumerateGroupsWithTypes:ALAssetsGroupAll usingBlock: 94 | ^(ALAssetsGroup *group, BOOL *stop) { 95 | [group setAssetsFilter:[ALAssetsFilter allPhotos]]; 96 | [group enumerateAssetsWithOptions:NSEnumerationReverse usingBlock:^(ALAsset *asset, NSUInteger index, BOOL *innerStop) { 97 | if (asset) { 98 | [self.assets addObject:asset]; 99 | } else { 100 | [self.collectionView reloadData]; 101 | } 102 | }]; 103 | } failureBlock: ^(NSError *error) { 104 | NSLog(@"Enumerate groups failed: %@",error); 105 | }]; 106 | } 107 | 108 | - (void)onToggleMultipanelSide:(NSNotification*)notification { 109 | [self updateLayout]; 110 | } 111 | 112 | - (void)updateLayout { 113 | UICollectionViewFlowLayout* layout = (UICollectionViewFlowLayout*)self.collectionView.collectionViewLayout; 114 | 115 | CGFloat width = (self.view.frame.size.width - 2 * ContainerPadding - ((ImagesPerLine - 1) * CellMargin)) / ImagesPerLine; 116 | 117 | layout.itemSize = CGSizeMake(width, width); 118 | [self.collectionView setCollectionViewLayout:layout animated:NO]; 119 | } 120 | 121 | @end 122 | -------------------------------------------------------------------------------- /demo/TRMultipanelViewControllerDemo/TRMultipanelViewControllerDemo/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "ipad", 5 | "size" : "29x29", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "ipad", 10 | "size" : "29x29", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "ipad", 15 | "size" : "40x40", 16 | "scale" : "1x" 17 | }, 18 | { 19 | "idiom" : "ipad", 20 | "size" : "40x40", 21 | "scale" : "2x" 22 | }, 23 | { 24 | "idiom" : "ipad", 25 | "size" : "76x76", 26 | "scale" : "1x" 27 | }, 28 | { 29 | "idiom" : "ipad", 30 | "size" : "76x76", 31 | "scale" : "2x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /demo/TRMultipanelViewControllerDemo/TRMultipanelViewControllerDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.bondur.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations~ipad 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationPortraitUpsideDown 37 | UIInterfaceOrientationLandscapeLeft 38 | UIInterfaceOrientationLandscapeRight 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /demo/TRMultipanelViewControllerDemo/TRMultipanelViewControllerDemo/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // Created by Vitali Bondur on 1/18/15. 4 | // 5 | 6 | #import 7 | 8 | @interface ViewController : UIViewController 9 | 10 | 11 | @end 12 | 13 | -------------------------------------------------------------------------------- /demo/TRMultipanelViewControllerDemo/TRMultipanelViewControllerDemo/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // Created by Vitali Bondur on 1/18/15. 4 | // 5 | 6 | #import "ViewController.h" 7 | 8 | #import "CollectionViewController.h" 9 | 10 | #import 11 | 12 | @interface ViewController () 13 | 14 | @property (strong, nonatomic) TRMultipanelViewController* multipanel; 15 | 16 | - (IBAction)leftPanelDidToggle:(id)sender; 17 | - (IBAction)rightPanelDidToggle:(id)sender; 18 | 19 | @end 20 | 21 | @implementation ViewController 22 | 23 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 24 | if ([segue.identifier isEqualToString:@"multipanel"]) { 25 | self.multipanel = segue.destinationViewController; 26 | 27 | [self.multipanel setConnectCenterViewToSides:YES]; 28 | [self.multipanel setWidth:240 forSide:TRMultipanelSideTypeLeft]; 29 | [self.multipanel setWidth:240 forSide:TRMultipanelSideTypeRight]; 30 | 31 | CollectionViewController* centerController = [self.storyboard instantiateViewControllerWithIdentifier:@"centerController"]; 32 | centerController.updateAfterResize = self.multipanel.connectCenterViewToSides; 33 | [self.multipanel setCenterController:centerController]; 34 | 35 | UITableViewController* leftController = [self.storyboard instantiateViewControllerWithIdentifier:@"leftController"]; 36 | [self.multipanel setContentController:leftController 37 | forSide:TRMultipanelSideTypeLeft]; 38 | 39 | UITableViewController* rightController = [self.storyboard instantiateViewControllerWithIdentifier:@"rightController"]; 40 | [self.multipanel setContentController:rightController 41 | forSide:TRMultipanelSideTypeRight]; 42 | } 43 | } 44 | 45 | - (IBAction)leftPanelDidToggle:(id)sender { 46 | [self.multipanel toggleSide:TRMultipanelSideTypeLeft animated:YES]; 47 | } 48 | 49 | - (IBAction)rightPanelDidToggle:(id)sender { 50 | [self.multipanel toggleSide:TRMultipanelSideTypeRight animated:YES]; 51 | } 52 | 53 | @end 54 | -------------------------------------------------------------------------------- /demo/TRMultipanelViewControllerDemo/TRMultipanelViewControllerDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // Created by Vitali Bondur on 1/18/15. 4 | // 5 | 6 | #import 7 | #import "AppDelegate.h" 8 | 9 | int main(int argc, char * argv[]) { 10 | @autoreleasepool { 11 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /demo/TRMultipanelViewControllerDemo/TRMultipanelViewControllerDemoTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.bondur.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /demo/TRMultipanelViewControllerDemo/TRMultipanelViewControllerDemoTests/TRMultipanelViewControllerDemoTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // TRMultipanelViewControllerDemoTests.m 3 | // Created by Vitali Bondur on 1/18/15. 4 | // 5 | 6 | #import 7 | #import 8 | 9 | @interface TRMultipanelViewControllerDemoTests : XCTestCase 10 | 11 | @end 12 | 13 | @implementation TRMultipanelViewControllerDemoTests 14 | 15 | - (void)setUp { 16 | [super setUp]; 17 | // Put setup code here. This method is called before the invocation of each test method in the class. 18 | } 19 | 20 | - (void)tearDown { 21 | // Put teardown code here. This method is called after the invocation of each test method in the class. 22 | [super tearDown]; 23 | } 24 | 25 | - (void)testExample { 26 | // This is an example of a functional test case. 27 | XCTAssert(YES, @"Pass"); 28 | } 29 | 30 | - (void)testPerformanceExample { 31 | // This is an example of a performance test case. 32 | [self measureBlock:^{ 33 | // Put the code you want to measure the time of here. 34 | }]; 35 | } 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /multipanel-demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caff31ne/TRMultipanelViewController/21edfab21ba77bc89936fd23b2130f9bd3ed26ae/multipanel-demo.gif -------------------------------------------------------------------------------- /multipanel/TRMultipanelViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // TrMultipanelViewController.h 3 | // Created by Vitali Bondur on 3/23/14. 4 | // 5 | 6 | #import 7 | 8 | @class TRMultipanelViewController; 9 | 10 | extern NSString* const TRMultipanelWillShowSideNotification; 11 | extern NSString* const TRMultipanelDidShowSideNotification; 12 | extern NSString* const TRMultipanelWillHideSideNotification; 13 | extern NSString* const TRMultipanelDidHideSideNotification; 14 | 15 | typedef NS_ENUM(NSInteger, TRMultipanelSideType) { 16 | TRMultipanelSideTypeUnknown, 17 | TRMultipanelSideTypeLeft, 18 | TRMultipanelSideTypeRight 19 | }; 20 | 21 | @protocol TRMultipanelViewControllerDelegate 22 | 23 | @optional 24 | - (BOOL)multipanel:(TRMultipanelViewController*)multipanel side:(TRMultipanelSideType)sideType shouldReceiveTouch:(UITouch *)touch; 25 | 26 | @end 27 | 28 | @interface TRMultipanelViewController : UIViewController 29 | 30 | @property (weak, nonatomic) id delegate; 31 | @property (strong, nonatomic) UIView* centerView; 32 | @property (strong, nonatomic) UIViewController* centerController; 33 | @property (assign, nonatomic) BOOL connectCenterViewToSides; 34 | 35 | - (UIViewController*)contentControllerForSide:(TRMultipanelSideType)side; 36 | - (void)setContentController:(UIViewController*)controller forSide:(TRMultipanelSideType)side; 37 | 38 | - (BOOL)isVisibleSide:(TRMultipanelSideType)side; 39 | 40 | - (CGFloat)widthForSide:(TRMultipanelSideType)side; 41 | - (void)setWidth:(CGFloat)width forSide:(TRMultipanelSideType)side; 42 | 43 | - (void)showSide:(TRMultipanelSideType)side 44 | animated:(BOOL)animated; 45 | 46 | - (void)hideSide:(TRMultipanelSideType)side 47 | animated:(BOOL)animated; 48 | 49 | - (void)toggleSide:(TRMultipanelSideType)side 50 | animated:(BOOL)animated; 51 | 52 | - (void)showSide:(TRMultipanelSideType)sideType 53 | animated:(BOOL)animated 54 | completion:(void (^)(TRMultipanelSideType sideType, BOOL finished))completionBlock; 55 | 56 | - (void)hideSide:(TRMultipanelSideType)sideType 57 | animated:(BOOL)animated 58 | completion:(void (^)(TRMultipanelSideType sideType, BOOL finished))completionBlock; 59 | 60 | - (void)toggleSide:(TRMultipanelSideType)sideType 61 | animated:(BOOL)animated 62 | completion:(void (^)(TRMultipanelSideType sideType, BOOL finished))completionBlock; 63 | @end 64 | -------------------------------------------------------------------------------- /multipanel/TRMultipanelViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // TrMultipanelViewController.m 3 | // Created by Vitali Bondur on 3/23/14. 4 | // 5 | 6 | #import "TRMultipanelViewController.h" 7 | 8 | #import "TRMultipanelViewControllerSide.h" 9 | 10 | #import "UIView+TRMultipanel.h" 11 | 12 | NSString* const TRMultipanelWillShowSideNotification = @"TRMultipanelWillShowSideNotification"; 13 | NSString* const TRMultipanelDidShowSideNotification = @"TRMultipanelDidShowSideNotification"; 14 | NSString* const TRMultipanelWillHideSideNotification = @"TRMultipanelWillHideSideNotification"; 15 | NSString* const TRMultipanelDidHideSideNotification = @"TRMultipanelDidHideSideNotification"; 16 | 17 | static const CGFloat TRMultipanelToggleAnimationDuration = 0.5; 18 | static const CGFloat TRMultipanelDefaultSideWith = 320.0; 19 | 20 | @interface TRMultipanelViewController () 21 | 22 | @property (strong, nonatomic) NSDictionary* sides; 23 | 24 | @end 25 | 26 | @implementation TRMultipanelViewController 27 | 28 | - (void)viewDidLoad 29 | { 30 | [super viewDidLoad]; 31 | } 32 | 33 | #pragma mark -- Public 34 | 35 | - (void)setCenterController:(UIViewController*)centerController { 36 | if (_centerController != centerController) { 37 | if (_centerController) { 38 | [_centerController removeFromParentViewController]; 39 | [_centerController.view removeFromSuperview]; 40 | } 41 | 42 | _centerController = centerController; 43 | 44 | if (centerController) { 45 | [self addChildViewController:centerController]; 46 | 47 | centerController.view.translatesAutoresizingMaskIntoConstraints = NO; 48 | centerController.view.frame = self.centerView.bounds; 49 | [self.centerView addSubview:centerController.view]; 50 | [centerController.view tieToSuperview]; 51 | } 52 | } 53 | } 54 | 55 | - (UIViewController*)contentControllerForSide:(TRMultipanelSideType)sideType { 56 | TRMultipanelViewControllerSide* side = [self sideWithType:sideType]; 57 | return side.contentController; 58 | } 59 | 60 | - (void)setContentController:(UIViewController*)controller 61 | forSide:(TRMultipanelSideType)sideType { 62 | TRMultipanelViewControllerSide* side = [self sideWithType:sideType]; 63 | side.contentController = controller; 64 | } 65 | 66 | - (BOOL)isVisibleSide:(TRMultipanelSideType)sideType { 67 | TRMultipanelViewControllerSide* side = [self sideWithType:sideType]; 68 | return side.visible; 69 | } 70 | 71 | - (CGFloat)widthForSide:(TRMultipanelSideType)sideType { 72 | TRMultipanelViewControllerSide* side = [self sideWithType:sideType]; 73 | return side.width; 74 | } 75 | 76 | - (void)setWidth:(CGFloat)width 77 | forSide:(TRMultipanelSideType)sideType { 78 | TRMultipanelViewControllerSide* side = [self sideWithType:sideType]; 79 | side.width = width; 80 | } 81 | 82 | #pragma mark -- Private 83 | 84 | - (UIView*)centerView { 85 | if (!_centerView) { 86 | _centerView = [[UIView alloc] init]; 87 | _centerView.translatesAutoresizingMaskIntoConstraints = NO; 88 | [self.view insertSubview:_centerView atIndex:0]; 89 | [self addCenterConstraints]; 90 | [_centerView setNeedsLayout]; 91 | [_centerView layoutIfNeeded]; 92 | } 93 | return _centerView; 94 | } 95 | 96 | - (NSDictionary*)sides { 97 | if (!_sides) { 98 | 99 | TRMultipanelViewControllerSide* leftSide = 100 | [[TRMultipanelViewControllerSide alloc] initWithContainer:self 101 | boundaryConnectionAttribute:NSLayoutAttributeLeading 102 | width:TRMultipanelDefaultSideWith]; 103 | leftSide.delegate = self; 104 | TRMultipanelViewControllerSide* rightSide = 105 | [[TRMultipanelViewControllerSide alloc] initWithContainer:self 106 | boundaryConnectionAttribute:NSLayoutAttributeTrailing 107 | width:TRMultipanelDefaultSideWith]; 108 | rightSide.delegate = self; 109 | 110 | _sides = @{ 111 | @(TRMultipanelSideTypeLeft): leftSide, 112 | @(TRMultipanelSideTypeRight): rightSide 113 | }; 114 | } 115 | return _sides; 116 | } 117 | 118 | - (TRMultipanelViewControllerSide*)sideWithType:(TRMultipanelSideType)type { 119 | return self.sides[@(type)]; 120 | } 121 | 122 | - (TRMultipanelSideType)typeOfSide:(TRMultipanelViewControllerSide*)side { 123 | for (NSNumber* key in self.sides) { 124 | if ([self.sides[key] isEqual:side]) { 125 | return [key integerValue]; 126 | } 127 | } 128 | return TRMultipanelSideTypeUnknown; 129 | } 130 | 131 | - (void)tieCenterViewToSides { 132 | TRMultipanelViewControllerSide* leftSide = [self sideWithType:TRMultipanelSideTypeLeft]; 133 | 134 | NSLayoutConstraint* leftCenterConstraint = [NSLayoutConstraint constraintWithItem:self.centerView 135 | attribute:NSLayoutAttributeLeading 136 | relatedBy:NSLayoutRelationEqual 137 | toItem:leftSide.view 138 | attribute:NSLayoutAttributeTrailing 139 | multiplier:1 140 | constant:0]; 141 | leftSide.centerEdgeConstraint = leftCenterConstraint; 142 | 143 | TRMultipanelViewControllerSide* rightSide = [self sideWithType:TRMultipanelSideTypeRight]; 144 | 145 | NSLayoutConstraint* rightCenterConstraint = [NSLayoutConstraint constraintWithItem:rightSide.view 146 | attribute:NSLayoutAttributeLeading 147 | relatedBy:NSLayoutRelationEqual 148 | toItem:self.centerView 149 | attribute:NSLayoutAttributeTrailing 150 | multiplier:1 151 | constant:0]; 152 | rightCenterConstraint.priority = 999; 153 | rightSide.centerEdgeConstraint = rightCenterConstraint; 154 | 155 | [self.view addConstraints:@[leftCenterConstraint, rightCenterConstraint]]; 156 | } 157 | 158 | - (void)tieCenterViewToSuperview { 159 | 160 | TRMultipanelViewControllerSide* leftSide = [self sideWithType:TRMultipanelSideTypeLeft]; 161 | 162 | NSLayoutConstraint* leftCenterConstraint = [NSLayoutConstraint constraintWithItem:self.centerView 163 | attribute:NSLayoutAttributeLeading 164 | relatedBy:NSLayoutRelationEqual 165 | toItem:self.centerView.superview 166 | attribute:NSLayoutAttributeLeading 167 | multiplier:1 168 | constant:0]; 169 | leftSide.centerEdgeConstraint = leftCenterConstraint; 170 | 171 | TRMultipanelViewControllerSide* rightSide = [self sideWithType:TRMultipanelSideTypeRight]; 172 | 173 | NSLayoutConstraint* rightCenterConstraint = [NSLayoutConstraint constraintWithItem:self.centerView.superview 174 | attribute:NSLayoutAttributeTrailing 175 | relatedBy:NSLayoutRelationEqual 176 | toItem:self.centerView 177 | attribute:NSLayoutAttributeTrailing 178 | multiplier:1 179 | constant:0]; 180 | rightCenterConstraint.priority = 999; 181 | rightSide.centerEdgeConstraint = rightCenterConstraint; 182 | 183 | [self.view addConstraints:@[leftCenterConstraint, rightCenterConstraint]]; 184 | } 185 | 186 | - (void)addCenterConstraints { 187 | NSLayoutConstraint* topCenterConstraint = [NSLayoutConstraint constraintWithItem:self.centerView 188 | attribute:NSLayoutAttributeTop 189 | relatedBy:NSLayoutRelationEqual 190 | toItem:self.view 191 | attribute:NSLayoutAttributeTop 192 | multiplier:1 193 | constant:0]; 194 | NSLayoutConstraint* bottomCenterConstraint = [NSLayoutConstraint constraintWithItem:self.centerView 195 | attribute:NSLayoutAttributeBottom 196 | relatedBy:NSLayoutRelationEqual 197 | toItem:self.view 198 | attribute:NSLayoutAttributeBottom 199 | multiplier:1 200 | constant:0]; 201 | 202 | if (self.connectCenterViewToSides) 203 | [self tieCenterViewToSuperview]; 204 | else 205 | [self tieCenterViewToSides]; 206 | 207 | [self.view addConstraints:@[topCenterConstraint, bottomCenterConstraint]]; 208 | } 209 | 210 | 211 | #pragma mark -- Actions 212 | 213 | - (void)showSide:(TRMultipanelSideType)sideType 214 | animated:(BOOL)animated 215 | { 216 | [self showSide:sideType 217 | animated:animated 218 | completion:nil]; 219 | } 220 | 221 | - (void)hideSide:(TRMultipanelSideType)sideType 222 | animated:(BOOL)animated 223 | { 224 | [self hideSide:sideType 225 | animated:animated 226 | completion:nil]; 227 | } 228 | 229 | - (void)toggleSide:(TRMultipanelSideType)sideType 230 | animated:(BOOL)animated 231 | { 232 | [self toggleSide:sideType 233 | animated:animated 234 | completion:nil]; 235 | } 236 | 237 | - (void)showSide:(TRMultipanelSideType)sideType 238 | animated:(BOOL)animated 239 | completion:(void (^)(TRMultipanelSideType sideType, BOOL finished))completion 240 | { 241 | 242 | [[NSNotificationCenter defaultCenter] postNotificationName:TRMultipanelWillShowSideNotification 243 | object:self 244 | userInfo:@{@"side":@(sideType)}]; 245 | 246 | __weak typeof(self) weakSelf = self; 247 | [self moveSide:sideType 248 | animated:animated 249 | operation: 250 | ^(TRMultipanelViewControllerSide* side) { 251 | side.visible = YES; 252 | } 253 | completion: 254 | ^(TRMultipanelSideType sideType, BOOL finished) { 255 | 256 | typeof(self) strongSelf = weakSelf; 257 | 258 | if (strongSelf.connectCenterViewToSides) { 259 | TRMultipanelViewControllerSide* side = [strongSelf sideWithType:sideType]; 260 | side.centerEdgeConstraint.constant = side.width; 261 | [strongSelf.centerView layoutIfNeeded]; 262 | } 263 | 264 | if (completion) 265 | completion(sideType, finished); 266 | 267 | [[NSNotificationCenter defaultCenter] postNotificationName:TRMultipanelDidShowSideNotification 268 | object:strongSelf 269 | userInfo:@{@"side":@(sideType)}]; 270 | }]; 271 | } 272 | 273 | - (void)hideSide:(TRMultipanelSideType)sideType 274 | animated:(BOOL)animated 275 | completion:(void (^)(TRMultipanelSideType sideType, BOOL finished))completion 276 | { 277 | if (self.connectCenterViewToSides) { 278 | TRMultipanelViewControllerSide* side = [self sideWithType:sideType]; 279 | side.centerEdgeConstraint.constant = 0; 280 | [self.centerView layoutIfNeeded]; 281 | } 282 | 283 | [[NSNotificationCenter defaultCenter] postNotificationName:TRMultipanelWillHideSideNotification 284 | object:self 285 | userInfo:@{@"side":@(sideType)}]; 286 | 287 | __weak typeof(self) weakSelf = self; 288 | [self moveSide:sideType 289 | animated:animated 290 | operation: 291 | ^(TRMultipanelViewControllerSide* side) { 292 | side.visible = NO; 293 | } 294 | completion: 295 | ^(TRMultipanelSideType sideType, BOOL finished) { 296 | 297 | typeof(self) strongSelf = weakSelf; 298 | 299 | if (completion) 300 | completion(sideType, finished); 301 | 302 | [[NSNotificationCenter defaultCenter] postNotificationName:TRMultipanelDidHideSideNotification 303 | object:strongSelf 304 | userInfo:@{@"side":@(sideType)}]; 305 | }]; 306 | } 307 | 308 | - (void)toggleSide:(TRMultipanelSideType)sideType 309 | animated:(BOOL)animated 310 | completion:(void (^)(TRMultipanelSideType sideType, BOOL finished))completion 311 | { 312 | TRMultipanelViewControllerSide* side = [self sideWithType:sideType]; 313 | 314 | if (side.visible) 315 | [self hideSide:sideType animated:animated completion:completion]; 316 | else 317 | [self showSide:sideType animated:animated completion:completion]; 318 | } 319 | 320 | - (void)moveSide:(TRMultipanelSideType)sideType 321 | animated:(BOOL)animated 322 | operation:(void (^)(TRMultipanelViewControllerSide* side))operation 323 | completion:(void (^)(TRMultipanelSideType sideType, BOOL finished))completion 324 | { 325 | __weak TRMultipanelViewControllerSide* side = [self sideWithType:sideType]; 326 | if (animated) { 327 | [UIView animateWithDuration:TRMultipanelToggleAnimationDuration 328 | animations: 329 | ^{ 330 | operation(side); 331 | } completion:^(BOOL finished) { 332 | if (completion) 333 | completion(sideType, finished); 334 | }]; 335 | } else { 336 | operation(side); 337 | if (completion) 338 | completion(sideType, YES); 339 | } 340 | } 341 | 342 | #pragma mark -- TRMultipanelViewControllerSideDelegate 343 | 344 | - (void)multipanelSideDidPanOutside:(TRMultipanelViewControllerSide*)side { 345 | TRMultipanelSideType sideType = [self typeOfSide:side]; 346 | [self hideSide:sideType animated:YES]; 347 | } 348 | 349 | - (BOOL)multipanelSide:(TRMultipanelViewControllerSide*)side shouldReceiveTouch:(UITouch *)touch { 350 | if ([self.delegate respondsToSelector:@selector(multipanel:side:shouldReceiveTouch:)]) 351 | return [self.delegate multipanel:self side:[self typeOfSide:side] shouldReceiveTouch:touch]; 352 | else 353 | return YES; 354 | } 355 | 356 | @end 357 | -------------------------------------------------------------------------------- /multipanel/TRMultipanelViewControllerSide.h: -------------------------------------------------------------------------------- 1 | // 2 | // TRMultipanelViewControllerSide.h 3 | // Created by Vitali Bondur on 1/17/15. 4 | // 5 | 6 | #import 7 | 8 | @class TRMultipanelViewController; 9 | @class TRMultipanelViewControllerSide; 10 | 11 | @protocol TRMultipanelViewControllerSideDelegate 12 | 13 | - (void)multipanelSideDidPanOutside:(TRMultipanelViewControllerSide*)side; 14 | - (BOOL)multipanelSide:(TRMultipanelViewControllerSide*)side shouldReceiveTouch:(UITouch *)touch; 15 | 16 | @end 17 | 18 | @interface TRMultipanelViewControllerSide : NSObject 19 | 20 | @property (weak, nonatomic) id delegate; 21 | @property (strong, nonatomic) UIViewController* contentController; 22 | @property (assign, nonatomic) BOOL visible; 23 | @property (assign, nonatomic) CGFloat width; 24 | @property (strong, nonatomic) UIView* view; 25 | @property (weak, nonatomic) NSLayoutConstraint* centerEdgeConstraint; 26 | 27 | - (instancetype)initWithContainer:(TRMultipanelViewController*)container 28 | boundaryConnectionAttribute:(NSLayoutAttribute)boundaryConnectionAttribute 29 | width:(CGFloat)width; 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /multipanel/TRMultipanelViewControllerSide.m: -------------------------------------------------------------------------------- 1 | // 2 | // TRMultipanelViewControllerSide.m 3 | // Created by Vitali Bondur on 1/17/15. 4 | // 5 | 6 | #import "TRMultipanelViewControllerSide.h" 7 | #import "TRMultipanelViewController.h" 8 | 9 | #import "UIView+TRMultipanel.h" 10 | 11 | static const int TRPanActionThreshold = 100; 12 | 13 | @interface TRMultipanelViewControllerSide () 14 | 15 | @property (weak, nonatomic) UIViewController* container; 16 | @property (assign, nonatomic) NSLayoutAttribute boundaryConnectionAttribute; 17 | 18 | @property (nonatomic, strong) NSLayoutConstraint* positionConstraint; 19 | @property (nonatomic, strong) NSLayoutConstraint* widthConstraint; 20 | 21 | @end 22 | 23 | @implementation TRMultipanelViewControllerSide 24 | 25 | - (instancetype)initWithContainer:(TRMultipanelViewController*)container 26 | boundaryConnectionAttribute:(NSLayoutAttribute)boundaryConnectionAttribute 27 | width:(CGFloat)width 28 | { 29 | self = [super init]; 30 | if (self) { 31 | self.container = container; 32 | self.boundaryConnectionAttribute = boundaryConnectionAttribute; 33 | self.width = width; 34 | self.view = [[UIView alloc] init]; 35 | } 36 | return self; 37 | } 38 | 39 | - (void)setView:(UIView*)view { 40 | if (_view != view) { 41 | if (_view) 42 | [_view removeFromSuperview]; 43 | _view = view; 44 | 45 | if (_view) 46 | [self addViewToContainer]; 47 | } 48 | } 49 | 50 | - (void)setWidth:(CGFloat)width { 51 | if (_width != width) { 52 | _width = width; 53 | 54 | if (self.widthConstraint) { 55 | self.widthConstraint.constant = width; 56 | if (self.positionConstraint.constant) { 57 | self.positionConstraint.constant = -self.width; 58 | } 59 | [self.view setNeedsLayout]; 60 | [self.view layoutIfNeeded]; 61 | } 62 | } 63 | } 64 | 65 | - (void)setContentController:(UIViewController *)contentController { 66 | if (_contentController != contentController) { 67 | if (_contentController) { 68 | [_contentController.view removeFromSuperview]; 69 | [_contentController removeFromParentViewController]; 70 | } 71 | 72 | _contentController = contentController; 73 | 74 | if (_contentController) { 75 | _contentController.view.translatesAutoresizingMaskIntoConstraints = NO; 76 | [self.container addChildViewController:_contentController]; 77 | [self.view addSubview:_contentController.view]; 78 | [_contentController.view tieToSuperview]; 79 | [_contentController.view setNeedsLayout]; 80 | [_contentController.view layoutIfNeeded]; 81 | } 82 | } 83 | } 84 | 85 | - (NSArray*)viewSequenceWithView:(UIView*)view 86 | forLayoutAttribute:(NSLayoutAttribute)attribute 87 | { 88 | if (attribute == NSLayoutAttributeTrailing) { 89 | return @[view.superview, view]; 90 | } else { 91 | return @[view, view.superview]; 92 | } 93 | } 94 | 95 | - (void)addViewToContainer { 96 | 97 | self.view.translatesAutoresizingMaskIntoConstraints = NO; 98 | [self.container.view addSubview:self.view]; 99 | 100 | self.widthConstraint = [NSLayoutConstraint constraintWithItem:self.view 101 | attribute:NSLayoutAttributeWidth 102 | relatedBy:NSLayoutRelationEqual 103 | toItem:nil 104 | attribute:NSLayoutAttributeWidth 105 | multiplier:1 106 | constant:self.width]; 107 | 108 | NSArray* views = [self viewSequenceWithView:self.view 109 | forLayoutAttribute:self.boundaryConnectionAttribute]; 110 | 111 | self.positionConstraint = [NSLayoutConstraint constraintWithItem:[views objectAtIndex:0] 112 | attribute:self.boundaryConnectionAttribute 113 | relatedBy:NSLayoutRelationEqual 114 | toItem:[views objectAtIndex:1] 115 | attribute:self.boundaryConnectionAttribute 116 | multiplier:1 117 | constant:-self.width]; 118 | 119 | NSLayoutConstraint* topConstraint = [NSLayoutConstraint constraintWithItem:self.view 120 | attribute:NSLayoutAttributeTop 121 | relatedBy:NSLayoutRelationEqual 122 | toItem:self.container.view 123 | attribute:NSLayoutAttributeTop 124 | multiplier:1 125 | constant:0]; 126 | 127 | NSLayoutConstraint* bottomConstraint = [NSLayoutConstraint constraintWithItem:self.view 128 | attribute:NSLayoutAttributeBottom 129 | relatedBy:NSLayoutRelationEqual 130 | toItem:self.container.view 131 | attribute:NSLayoutAttributeBottom 132 | multiplier:1 133 | constant:0]; 134 | 135 | [self.view addConstraint:self.widthConstraint]; 136 | [self.container.view addConstraints:@[topConstraint, bottomConstraint, self.positionConstraint]]; 137 | 138 | [self addGestureRecognizer]; 139 | } 140 | 141 | - (void)addGestureRecognizer { 142 | UIPanGestureRecognizer* gestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(onPan:)]; 143 | gestureRecognizer.delegate = self; 144 | [self.view addGestureRecognizer:gestureRecognizer]; 145 | } 146 | 147 | - (CGFloat)applyTranslation:(UIPanGestureRecognizer*)gestureRecognizer { 148 | CGPoint translation = [gestureRecognizer translationInView:self.container.view]; 149 | 150 | switch (self.boundaryConnectionAttribute) { 151 | case NSLayoutAttributeLeading: 152 | if (translation.x < 0) { 153 | self.positionConstraint.constant = translation.x; 154 | } 155 | break; 156 | case NSLayoutAttributeTrailing: 157 | if (translation.x > 0) { 158 | self.positionConstraint.constant = -translation.x; 159 | } 160 | break; 161 | default: 162 | break; 163 | } 164 | return self.positionConstraint.constant; 165 | } 166 | 167 | - (void)onPan:(UIPanGestureRecognizer*)gestureRecognizer { 168 | 169 | switch (gestureRecognizer.state) { 170 | case UIGestureRecognizerStateBegan: 171 | case UIGestureRecognizerStateChanged: 172 | [self applyTranslation:gestureRecognizer]; 173 | break; 174 | case UIGestureRecognizerStateEnded: 175 | [self applyTranslation:gestureRecognizer]; 176 | if (-self.positionConstraint.constant > TRPanActionThreshold) { 177 | [self.delegate multipanelSideDidPanOutside:self]; 178 | } else { 179 | self.positionConstraint.constant = 0; 180 | } 181 | break; 182 | default: 183 | break; 184 | } 185 | } 186 | 187 | - (BOOL)visible { 188 | return self.positionConstraint.constant != -self.width; 189 | } 190 | 191 | - (void)setVisible:(BOOL)visible { 192 | if (visible) { 193 | self.positionConstraint.constant = 0; 194 | } else { 195 | self.positionConstraint.constant = -self.width; 196 | } 197 | [self.view setNeedsLayout]; 198 | [self.view layoutIfNeeded]; 199 | } 200 | 201 | #pragma mark UIGestureRecognizerDelegate 202 | 203 | - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch { 204 | return [self.delegate multipanelSide:self shouldReceiveTouch:touch]; 205 | } 206 | 207 | @end 208 | -------------------------------------------------------------------------------- /multipanel/UIView+TRMultipanel.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+TRMultipanel.h 3 | // Created by Vitali Bondur on 1/24/15. 4 | // 5 | 6 | #import 7 | 8 | @interface UIView (TRMultipanel) 9 | 10 | - (void)tieToSuperview; 11 | 12 | @end 13 | -------------------------------------------------------------------------------- /multipanel/UIView+TRMultipanel.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+TRMultipanel.m 3 | // Created by Vitali Bondur on 1/24/15. 4 | // 5 | 6 | #import "UIView+TRMultipanel.h" 7 | 8 | @implementation UIView (TRMultipanel) 9 | 10 | - (void)tieToSuperview { 11 | NSLayoutConstraint* topConstraint = [NSLayoutConstraint constraintWithItem:self.superview 12 | attribute:NSLayoutAttributeTop 13 | relatedBy:NSLayoutRelationEqual 14 | toItem:self 15 | attribute:NSLayoutAttributeTop 16 | multiplier:1 17 | constant:0]; 18 | NSLayoutConstraint* bottomConstraint = [NSLayoutConstraint constraintWithItem:self.superview 19 | attribute:NSLayoutAttributeBottom 20 | relatedBy:NSLayoutRelationEqual 21 | toItem:self 22 | attribute:NSLayoutAttributeBottom 23 | multiplier:1 24 | constant:0]; 25 | 26 | NSLayoutConstraint* leftConstraint = [NSLayoutConstraint constraintWithItem:self.superview 27 | attribute:NSLayoutAttributeLeading 28 | relatedBy:NSLayoutRelationEqual 29 | toItem:self 30 | attribute:NSLayoutAttributeLeading 31 | multiplier:1 32 | constant:0]; 33 | 34 | NSLayoutConstraint* rightConstraint = [NSLayoutConstraint constraintWithItem:self.superview 35 | attribute:NSLayoutAttributeTrailing 36 | relatedBy:NSLayoutRelationEqual 37 | toItem:self 38 | attribute:NSLayoutAttributeTrailing 39 | multiplier:1 40 | constant:0]; 41 | 42 | [self.superview addConstraints:@[topConstraint, bottomConstraint, leftConstraint, rightConstraint]]; 43 | } 44 | 45 | 46 | @end 47 | --------------------------------------------------------------------------------