├── .gitignore ├── App ├── PresentationControllers.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata ├── PresentationControllers │ ├── AppDelegate.swift │ ├── Base.lproj │ │ └── Main.storyboard │ ├── CustomPresentationAnimationController.swift │ ├── CustomPresentationController.swift │ ├── Images.xcassets │ │ ├── AppIcon.appiconset │ │ │ └── Contents.json │ │ └── LaunchImage.launchimage │ │ │ └── Contents.json │ ├── Info.plist │ ├── MessageViewController.swift │ ├── ViewController.swift │ └── background.JPG └── PresentationControllersTests │ ├── Info.plist │ └── PresentationControllersTests.swift ├── LICENSE ├── PresentationControllers.gif └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | .DS_Store 3 | 4 | # Xcode 5 | # 6 | build/ 7 | *.pbxuser 8 | !default.pbxuser 9 | *.mode1v3 10 | !default.mode1v3 11 | *.mode2v3 12 | !default.mode2v3 13 | *.perspectivev3 14 | !default.perspectivev3 15 | xcuserdata 16 | *.xccheckout 17 | *.moved-aside 18 | DerivedData 19 | *.hmap 20 | *.ipa 21 | *.xcuserstate 22 | 23 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control? 24 | Pods/ 25 | -------------------------------------------------------------------------------- /App/PresentationControllers.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | B547B3D9195C0A3B007C1656 /* background.JPG in Resources */ = {isa = PBXBuildFile; fileRef = B547B3D8195C0A3B007C1656 /* background.JPG */; }; 11 | B547B3DB195C0AC3007C1656 /* MessageViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B547B3DA195C0AC3007C1656 /* MessageViewController.swift */; }; 12 | B547B3DD195C10D2007C1656 /* CustomPresentationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B547B3DC195C10D2007C1656 /* CustomPresentationController.swift */; }; 13 | B547B3DF195C19FC007C1656 /* CustomPresentationAnimationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B547B3DE195C19FC007C1656 /* CustomPresentationAnimationController.swift */; }; 14 | B5FF35C8195C09E800170C7D /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5FF35C7195C09E800170C7D /* AppDelegate.swift */; }; 15 | B5FF35CA195C09E800170C7D /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5FF35C9195C09E800170C7D /* ViewController.swift */; }; 16 | B5FF35CD195C09E800170C7D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B5FF35CB195C09E800170C7D /* Main.storyboard */; }; 17 | B5FF35CF195C09E800170C7D /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B5FF35CE195C09E800170C7D /* Images.xcassets */; }; 18 | B5FF35DB195C09E800170C7D /* PresentationControllersTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5FF35DA195C09E800170C7D /* PresentationControllersTests.swift */; }; 19 | /* End PBXBuildFile section */ 20 | 21 | /* Begin PBXContainerItemProxy section */ 22 | B5FF35D5195C09E800170C7D /* PBXContainerItemProxy */ = { 23 | isa = PBXContainerItemProxy; 24 | containerPortal = B5FF35BA195C09E800170C7D /* Project object */; 25 | proxyType = 1; 26 | remoteGlobalIDString = B5FF35C1195C09E800170C7D; 27 | remoteInfo = PresentationControllers; 28 | }; 29 | /* End PBXContainerItemProxy section */ 30 | 31 | /* Begin PBXFileReference section */ 32 | B547B3D8195C0A3B007C1656 /* background.JPG */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = background.JPG; sourceTree = ""; }; 33 | B547B3DA195C0AC3007C1656 /* MessageViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MessageViewController.swift; sourceTree = ""; }; 34 | B547B3DC195C10D2007C1656 /* CustomPresentationController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CustomPresentationController.swift; sourceTree = ""; }; 35 | B547B3DE195C19FC007C1656 /* CustomPresentationAnimationController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CustomPresentationAnimationController.swift; sourceTree = ""; usesTabs = 0; }; 36 | B5FF35C2195C09E800170C7D /* PresentationControllers.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = PresentationControllers.app; sourceTree = BUILT_PRODUCTS_DIR; }; 37 | B5FF35C6195C09E800170C7D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 38 | B5FF35C7195C09E800170C7D /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 39 | B5FF35C9195C09E800170C7D /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 40 | B5FF35CC195C09E800170C7D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 41 | B5FF35CE195C09E800170C7D /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 42 | B5FF35D4195C09E800170C7D /* PresentationControllersTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = PresentationControllersTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 43 | B5FF35D9195C09E800170C7D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 44 | B5FF35DA195C09E800170C7D /* PresentationControllersTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PresentationControllersTests.swift; sourceTree = ""; }; 45 | /* End PBXFileReference section */ 46 | 47 | /* Begin PBXFrameworksBuildPhase section */ 48 | B5FF35BF195C09E800170C7D /* Frameworks */ = { 49 | isa = PBXFrameworksBuildPhase; 50 | buildActionMask = 2147483647; 51 | files = ( 52 | ); 53 | runOnlyForDeploymentPostprocessing = 0; 54 | }; 55 | B5FF35D1195C09E800170C7D /* Frameworks */ = { 56 | isa = PBXFrameworksBuildPhase; 57 | buildActionMask = 2147483647; 58 | files = ( 59 | ); 60 | runOnlyForDeploymentPostprocessing = 0; 61 | }; 62 | /* End PBXFrameworksBuildPhase section */ 63 | 64 | /* Begin PBXGroup section */ 65 | B5FF35B9195C09E800170C7D = { 66 | isa = PBXGroup; 67 | children = ( 68 | B5FF35C4195C09E800170C7D /* PresentationControllers */, 69 | B5FF35D7195C09E800170C7D /* PresentationControllersTests */, 70 | B5FF35C3195C09E800170C7D /* Products */, 71 | ); 72 | sourceTree = ""; 73 | }; 74 | B5FF35C3195C09E800170C7D /* Products */ = { 75 | isa = PBXGroup; 76 | children = ( 77 | B5FF35C2195C09E800170C7D /* PresentationControllers.app */, 78 | B5FF35D4195C09E800170C7D /* PresentationControllersTests.xctest */, 79 | ); 80 | name = Products; 81 | sourceTree = ""; 82 | }; 83 | B5FF35C4195C09E800170C7D /* PresentationControllers */ = { 84 | isa = PBXGroup; 85 | children = ( 86 | B5FF35C7195C09E800170C7D /* AppDelegate.swift */, 87 | B5FF35C9195C09E800170C7D /* ViewController.swift */, 88 | B547B3DA195C0AC3007C1656 /* MessageViewController.swift */, 89 | B547B3DC195C10D2007C1656 /* CustomPresentationController.swift */, 90 | B547B3DE195C19FC007C1656 /* CustomPresentationAnimationController.swift */, 91 | B5FF35CB195C09E800170C7D /* Main.storyboard */, 92 | B547B3D8195C0A3B007C1656 /* background.JPG */, 93 | B5FF35CE195C09E800170C7D /* Images.xcassets */, 94 | B5FF35C5195C09E800170C7D /* Supporting Files */, 95 | ); 96 | path = PresentationControllers; 97 | sourceTree = ""; 98 | }; 99 | B5FF35C5195C09E800170C7D /* Supporting Files */ = { 100 | isa = PBXGroup; 101 | children = ( 102 | B5FF35C6195C09E800170C7D /* Info.plist */, 103 | ); 104 | name = "Supporting Files"; 105 | sourceTree = ""; 106 | }; 107 | B5FF35D7195C09E800170C7D /* PresentationControllersTests */ = { 108 | isa = PBXGroup; 109 | children = ( 110 | B5FF35DA195C09E800170C7D /* PresentationControllersTests.swift */, 111 | B5FF35D8195C09E800170C7D /* Supporting Files */, 112 | ); 113 | path = PresentationControllersTests; 114 | sourceTree = ""; 115 | }; 116 | B5FF35D8195C09E800170C7D /* Supporting Files */ = { 117 | isa = PBXGroup; 118 | children = ( 119 | B5FF35D9195C09E800170C7D /* Info.plist */, 120 | ); 121 | name = "Supporting Files"; 122 | sourceTree = ""; 123 | }; 124 | /* End PBXGroup section */ 125 | 126 | /* Begin PBXNativeTarget section */ 127 | B5FF35C1195C09E800170C7D /* PresentationControllers */ = { 128 | isa = PBXNativeTarget; 129 | buildConfigurationList = B5FF35DE195C09E800170C7D /* Build configuration list for PBXNativeTarget "PresentationControllers" */; 130 | buildPhases = ( 131 | B5FF35BE195C09E800170C7D /* Sources */, 132 | B5FF35BF195C09E800170C7D /* Frameworks */, 133 | B5FF35C0195C09E800170C7D /* Resources */, 134 | ); 135 | buildRules = ( 136 | ); 137 | dependencies = ( 138 | ); 139 | name = PresentationControllers; 140 | productName = PresentationControllers; 141 | productReference = B5FF35C2195C09E800170C7D /* PresentationControllers.app */; 142 | productType = "com.apple.product-type.application"; 143 | }; 144 | B5FF35D3195C09E800170C7D /* PresentationControllersTests */ = { 145 | isa = PBXNativeTarget; 146 | buildConfigurationList = B5FF35E1195C09E800170C7D /* Build configuration list for PBXNativeTarget "PresentationControllersTests" */; 147 | buildPhases = ( 148 | B5FF35D0195C09E800170C7D /* Sources */, 149 | B5FF35D1195C09E800170C7D /* Frameworks */, 150 | B5FF35D2195C09E800170C7D /* Resources */, 151 | ); 152 | buildRules = ( 153 | ); 154 | dependencies = ( 155 | B5FF35D6195C09E800170C7D /* PBXTargetDependency */, 156 | ); 157 | name = PresentationControllersTests; 158 | productName = PresentationControllersTests; 159 | productReference = B5FF35D4195C09E800170C7D /* PresentationControllersTests.xctest */; 160 | productType = "com.apple.product-type.bundle.unit-test"; 161 | }; 162 | /* End PBXNativeTarget section */ 163 | 164 | /* Begin PBXProject section */ 165 | B5FF35BA195C09E800170C7D /* Project object */ = { 166 | isa = PBXProject; 167 | attributes = { 168 | LastSwiftUpdateCheck = 0710; 169 | LastUpgradeCheck = 0710; 170 | ORGANIZATIONNAME = "Dative Studios"; 171 | TargetAttributes = { 172 | B5FF35C1195C09E800170C7D = { 173 | CreatedOnToolsVersion = 6.0; 174 | }; 175 | B5FF35D3195C09E800170C7D = { 176 | CreatedOnToolsVersion = 6.0; 177 | TestTargetID = B5FF35C1195C09E800170C7D; 178 | }; 179 | }; 180 | }; 181 | buildConfigurationList = B5FF35BD195C09E800170C7D /* Build configuration list for PBXProject "PresentationControllers" */; 182 | compatibilityVersion = "Xcode 3.2"; 183 | developmentRegion = English; 184 | hasScannedForEncodings = 0; 185 | knownRegions = ( 186 | en, 187 | Base, 188 | ); 189 | mainGroup = B5FF35B9195C09E800170C7D; 190 | productRefGroup = B5FF35C3195C09E800170C7D /* Products */; 191 | projectDirPath = ""; 192 | projectRoot = ""; 193 | targets = ( 194 | B5FF35C1195C09E800170C7D /* PresentationControllers */, 195 | B5FF35D3195C09E800170C7D /* PresentationControllersTests */, 196 | ); 197 | }; 198 | /* End PBXProject section */ 199 | 200 | /* Begin PBXResourcesBuildPhase section */ 201 | B5FF35C0195C09E800170C7D /* Resources */ = { 202 | isa = PBXResourcesBuildPhase; 203 | buildActionMask = 2147483647; 204 | files = ( 205 | B5FF35CD195C09E800170C7D /* Main.storyboard in Resources */, 206 | B5FF35CF195C09E800170C7D /* Images.xcassets in Resources */, 207 | B547B3D9195C0A3B007C1656 /* background.JPG in Resources */, 208 | ); 209 | runOnlyForDeploymentPostprocessing = 0; 210 | }; 211 | B5FF35D2195C09E800170C7D /* Resources */ = { 212 | isa = PBXResourcesBuildPhase; 213 | buildActionMask = 2147483647; 214 | files = ( 215 | ); 216 | runOnlyForDeploymentPostprocessing = 0; 217 | }; 218 | /* End PBXResourcesBuildPhase section */ 219 | 220 | /* Begin PBXSourcesBuildPhase section */ 221 | B5FF35BE195C09E800170C7D /* Sources */ = { 222 | isa = PBXSourcesBuildPhase; 223 | buildActionMask = 2147483647; 224 | files = ( 225 | B547B3DD195C10D2007C1656 /* CustomPresentationController.swift in Sources */, 226 | B547B3DF195C19FC007C1656 /* CustomPresentationAnimationController.swift in Sources */, 227 | B5FF35CA195C09E800170C7D /* ViewController.swift in Sources */, 228 | B547B3DB195C0AC3007C1656 /* MessageViewController.swift in Sources */, 229 | B5FF35C8195C09E800170C7D /* AppDelegate.swift in Sources */, 230 | ); 231 | runOnlyForDeploymentPostprocessing = 0; 232 | }; 233 | B5FF35D0195C09E800170C7D /* Sources */ = { 234 | isa = PBXSourcesBuildPhase; 235 | buildActionMask = 2147483647; 236 | files = ( 237 | B5FF35DB195C09E800170C7D /* PresentationControllersTests.swift in Sources */, 238 | ); 239 | runOnlyForDeploymentPostprocessing = 0; 240 | }; 241 | /* End PBXSourcesBuildPhase section */ 242 | 243 | /* Begin PBXTargetDependency section */ 244 | B5FF35D6195C09E800170C7D /* PBXTargetDependency */ = { 245 | isa = PBXTargetDependency; 246 | target = B5FF35C1195C09E800170C7D /* PresentationControllers */; 247 | targetProxy = B5FF35D5195C09E800170C7D /* PBXContainerItemProxy */; 248 | }; 249 | /* End PBXTargetDependency section */ 250 | 251 | /* Begin PBXVariantGroup section */ 252 | B5FF35CB195C09E800170C7D /* Main.storyboard */ = { 253 | isa = PBXVariantGroup; 254 | children = ( 255 | B5FF35CC195C09E800170C7D /* Base */, 256 | ); 257 | name = Main.storyboard; 258 | sourceTree = ""; 259 | }; 260 | /* End PBXVariantGroup section */ 261 | 262 | /* Begin XCBuildConfiguration section */ 263 | B5FF35DC195C09E800170C7D /* Debug */ = { 264 | isa = XCBuildConfiguration; 265 | buildSettings = { 266 | ALWAYS_SEARCH_USER_PATHS = NO; 267 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 268 | CLANG_CXX_LIBRARY = "libc++"; 269 | CLANG_ENABLE_MODULES = YES; 270 | CLANG_ENABLE_OBJC_ARC = YES; 271 | CLANG_WARN_BOOL_CONVERSION = YES; 272 | CLANG_WARN_CONSTANT_CONVERSION = YES; 273 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 274 | CLANG_WARN_EMPTY_BODY = YES; 275 | CLANG_WARN_ENUM_CONVERSION = YES; 276 | CLANG_WARN_INT_CONVERSION = YES; 277 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 278 | CLANG_WARN_UNREACHABLE_CODE = YES; 279 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 280 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 281 | COPY_PHASE_STRIP = NO; 282 | ENABLE_STRICT_OBJC_MSGSEND = YES; 283 | ENABLE_TESTABILITY = YES; 284 | GCC_C_LANGUAGE_STANDARD = gnu99; 285 | GCC_DYNAMIC_NO_PIC = NO; 286 | GCC_OPTIMIZATION_LEVEL = 0; 287 | GCC_PREPROCESSOR_DEFINITIONS = ( 288 | "DEBUG=1", 289 | "$(inherited)", 290 | ); 291 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 292 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 293 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 294 | GCC_WARN_UNDECLARED_SELECTOR = YES; 295 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 296 | GCC_WARN_UNUSED_FUNCTION = YES; 297 | GCC_WARN_UNUSED_VARIABLE = YES; 298 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 299 | METAL_ENABLE_DEBUG_INFO = YES; 300 | ONLY_ACTIVE_ARCH = YES; 301 | SDKROOT = iphoneos; 302 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 303 | }; 304 | name = Debug; 305 | }; 306 | B5FF35DD195C09E800170C7D /* Release */ = { 307 | isa = XCBuildConfiguration; 308 | buildSettings = { 309 | ALWAYS_SEARCH_USER_PATHS = NO; 310 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 311 | CLANG_CXX_LIBRARY = "libc++"; 312 | CLANG_ENABLE_MODULES = YES; 313 | CLANG_ENABLE_OBJC_ARC = YES; 314 | CLANG_WARN_BOOL_CONVERSION = YES; 315 | CLANG_WARN_CONSTANT_CONVERSION = YES; 316 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 317 | CLANG_WARN_EMPTY_BODY = YES; 318 | CLANG_WARN_ENUM_CONVERSION = YES; 319 | CLANG_WARN_INT_CONVERSION = YES; 320 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 321 | CLANG_WARN_UNREACHABLE_CODE = YES; 322 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 323 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 324 | COPY_PHASE_STRIP = YES; 325 | ENABLE_NS_ASSERTIONS = NO; 326 | ENABLE_STRICT_OBJC_MSGSEND = YES; 327 | GCC_C_LANGUAGE_STANDARD = gnu99; 328 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 329 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 330 | GCC_WARN_UNDECLARED_SELECTOR = YES; 331 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 332 | GCC_WARN_UNUSED_FUNCTION = YES; 333 | GCC_WARN_UNUSED_VARIABLE = YES; 334 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 335 | METAL_ENABLE_DEBUG_INFO = NO; 336 | SDKROOT = iphoneos; 337 | VALIDATE_PRODUCT = YES; 338 | }; 339 | name = Release; 340 | }; 341 | B5FF35DF195C09E800170C7D /* Debug */ = { 342 | isa = XCBuildConfiguration; 343 | buildSettings = { 344 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 345 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 346 | INFOPLIST_FILE = PresentationControllers/Info.plist; 347 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 348 | PRODUCT_BUNDLE_IDENTIFIER = "com.dativestudios.${PRODUCT_NAME:rfc1034identifier}"; 349 | PRODUCT_NAME = "$(TARGET_NAME)"; 350 | }; 351 | name = Debug; 352 | }; 353 | B5FF35E0195C09E800170C7D /* Release */ = { 354 | isa = XCBuildConfiguration; 355 | buildSettings = { 356 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 357 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 358 | INFOPLIST_FILE = PresentationControllers/Info.plist; 359 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 360 | PRODUCT_BUNDLE_IDENTIFIER = "com.dativestudios.${PRODUCT_NAME:rfc1034identifier}"; 361 | PRODUCT_NAME = "$(TARGET_NAME)"; 362 | }; 363 | name = Release; 364 | }; 365 | B5FF35E2195C09E800170C7D /* Debug */ = { 366 | isa = XCBuildConfiguration; 367 | buildSettings = { 368 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/PresentationControllers.app/PresentationControllers"; 369 | FRAMEWORK_SEARCH_PATHS = ( 370 | "$(SDKROOT)/Developer/Library/Frameworks", 371 | "$(inherited)", 372 | ); 373 | GCC_PREPROCESSOR_DEFINITIONS = ( 374 | "DEBUG=1", 375 | "$(inherited)", 376 | ); 377 | INFOPLIST_FILE = PresentationControllersTests/Info.plist; 378 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 379 | METAL_ENABLE_DEBUG_INFO = YES; 380 | PRODUCT_BUNDLE_IDENTIFIER = "com.dativestudios.${PRODUCT_NAME:rfc1034identifier}"; 381 | PRODUCT_NAME = "$(TARGET_NAME)"; 382 | TEST_HOST = "$(BUNDLE_LOADER)"; 383 | }; 384 | name = Debug; 385 | }; 386 | B5FF35E3195C09E800170C7D /* Release */ = { 387 | isa = XCBuildConfiguration; 388 | buildSettings = { 389 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/PresentationControllers.app/PresentationControllers"; 390 | FRAMEWORK_SEARCH_PATHS = ( 391 | "$(SDKROOT)/Developer/Library/Frameworks", 392 | "$(inherited)", 393 | ); 394 | INFOPLIST_FILE = PresentationControllersTests/Info.plist; 395 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 396 | METAL_ENABLE_DEBUG_INFO = NO; 397 | PRODUCT_BUNDLE_IDENTIFIER = "com.dativestudios.${PRODUCT_NAME:rfc1034identifier}"; 398 | PRODUCT_NAME = "$(TARGET_NAME)"; 399 | TEST_HOST = "$(BUNDLE_LOADER)"; 400 | }; 401 | name = Release; 402 | }; 403 | /* End XCBuildConfiguration section */ 404 | 405 | /* Begin XCConfigurationList section */ 406 | B5FF35BD195C09E800170C7D /* Build configuration list for PBXProject "PresentationControllers" */ = { 407 | isa = XCConfigurationList; 408 | buildConfigurations = ( 409 | B5FF35DC195C09E800170C7D /* Debug */, 410 | B5FF35DD195C09E800170C7D /* Release */, 411 | ); 412 | defaultConfigurationIsVisible = 0; 413 | defaultConfigurationName = Release; 414 | }; 415 | B5FF35DE195C09E800170C7D /* Build configuration list for PBXNativeTarget "PresentationControllers" */ = { 416 | isa = XCConfigurationList; 417 | buildConfigurations = ( 418 | B5FF35DF195C09E800170C7D /* Debug */, 419 | B5FF35E0195C09E800170C7D /* Release */, 420 | ); 421 | defaultConfigurationIsVisible = 0; 422 | defaultConfigurationName = Release; 423 | }; 424 | B5FF35E1195C09E800170C7D /* Build configuration list for PBXNativeTarget "PresentationControllersTests" */ = { 425 | isa = XCConfigurationList; 426 | buildConfigurations = ( 427 | B5FF35E2195C09E800170C7D /* Debug */, 428 | B5FF35E3195C09E800170C7D /* Release */, 429 | ); 430 | defaultConfigurationIsVisible = 0; 431 | defaultConfigurationName = Release; 432 | }; 433 | /* End XCConfigurationList section */ 434 | }; 435 | rootObject = B5FF35BA195C09E800170C7D /* Project object */; 436 | } 437 | -------------------------------------------------------------------------------- /App/PresentationControllers.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /App/PresentationControllers/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // PresentationControllers 4 | // 5 | // Created by Pete Callaway on 26/06/2014. 6 | // Copyright (c) 2014 Dative Studios. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | } 16 | 17 | -------------------------------------------------------------------------------- /App/PresentationControllers/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 | 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 | 66 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | -------------------------------------------------------------------------------- /App/PresentationControllers/CustomPresentationAnimationController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Pete Callaway on 26/06/2014. 3 | // Copyright (c) 2014 Dative Studios. All rights reserved. 4 | // 5 | 6 | import UIKit 7 | 8 | 9 | class CustomPresentationAnimationController: NSObject, UIViewControllerAnimatedTransitioning { 10 | 11 | let isPresenting :Bool 12 | let duration :NSTimeInterval = 0.5 13 | 14 | init(isPresenting: Bool) { 15 | self.isPresenting = isPresenting 16 | 17 | super.init() 18 | } 19 | 20 | 21 | // ---- UIViewControllerAnimatedTransitioning methods 22 | 23 | func transitionDuration(transitionContext: UIViewControllerContextTransitioning?) -> NSTimeInterval { 24 | return self.duration 25 | } 26 | 27 | func animateTransition(transitionContext: UIViewControllerContextTransitioning) { 28 | if isPresenting { 29 | animatePresentationWithTransitionContext(transitionContext) 30 | } 31 | else { 32 | animateDismissalWithTransitionContext(transitionContext) 33 | } 34 | } 35 | 36 | 37 | // ---- Helper methods 38 | 39 | func animatePresentationWithTransitionContext(transitionContext: UIViewControllerContextTransitioning) { 40 | 41 | guard 42 | let presentedController = transitionContext.viewControllerForKey(UITransitionContextToViewControllerKey), 43 | let presentedControllerView = transitionContext.viewForKey(UITransitionContextToViewKey), 44 | let containerView = transitionContext.containerView() 45 | else { 46 | return 47 | } 48 | 49 | // Position the presented view off the top of the container view 50 | presentedControllerView.frame = transitionContext.finalFrameForViewController(presentedController) 51 | presentedControllerView.center.y -= containerView.bounds.size.height 52 | 53 | containerView.addSubview(presentedControllerView) 54 | 55 | // Animate the presented view to it's final position 56 | UIView.animateWithDuration(self.duration, delay: 0.0, usingSpringWithDamping: 1.0, initialSpringVelocity: 0.0, options: .AllowUserInteraction, animations: { 57 | presentedControllerView.center.y += containerView.bounds.size.height 58 | }, completion: {(completed: Bool) -> Void in 59 | transitionContext.completeTransition(completed) 60 | }) 61 | } 62 | 63 | func animateDismissalWithTransitionContext(transitionContext: UIViewControllerContextTransitioning) { 64 | 65 | guard 66 | let presentedControllerView = transitionContext.viewForKey(UITransitionContextFromViewKey), 67 | let containerView = transitionContext.containerView() 68 | else { 69 | return 70 | } 71 | 72 | // Animate the presented view off the bottom of the view 73 | UIView.animateWithDuration(self.duration, delay: 0.0, usingSpringWithDamping: 1.0, initialSpringVelocity: 0.0, options: .AllowUserInteraction, animations: { 74 | presentedControllerView.center.y += containerView.bounds.size.height 75 | }, completion: {(completed: Bool) -> Void in 76 | transitionContext.completeTransition(completed) 77 | }) 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /App/PresentationControllers/CustomPresentationController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Pete Callaway on 26/06/2014. 3 | // Copyright (c) 2014 Dative Studios. All rights reserved. 4 | // 5 | 6 | import UIKit 7 | 8 | 9 | class CustomPresentationController: UIPresentationController { 10 | 11 | lazy var dimmingView :UIView = { 12 | let view = UIView(frame: self.containerView!.bounds) 13 | view.backgroundColor = UIColor(red: 1.0, green: 0.0, blue: 0.0, alpha: 0.5) 14 | view.alpha = 0.0 15 | return view 16 | }() 17 | 18 | override func presentationTransitionWillBegin() { 19 | 20 | guard 21 | let containerView = containerView, 22 | let presentedView = presentedView() 23 | else { 24 | return 25 | } 26 | 27 | // Add the dimming view and the presented view to the heirarchy 28 | dimmingView.frame = containerView.bounds 29 | containerView.addSubview(dimmingView) 30 | containerView.addSubview(presentedView) 31 | 32 | // Fade in the dimming view alongside the transition 33 | if let transitionCoordinator = self.presentingViewController.transitionCoordinator() { 34 | transitionCoordinator.animateAlongsideTransition({(context: UIViewControllerTransitionCoordinatorContext!) -> Void in 35 | self.dimmingView.alpha = 1.0 36 | }, completion:nil) 37 | } 38 | } 39 | 40 | override func presentationTransitionDidEnd(completed: Bool) { 41 | // If the presentation didn't complete, remove the dimming view 42 | if !completed { 43 | self.dimmingView.removeFromSuperview() 44 | } 45 | } 46 | 47 | override func dismissalTransitionWillBegin() { 48 | // Fade out the dimming view alongside the transition 49 | if let transitionCoordinator = self.presentingViewController.transitionCoordinator() { 50 | transitionCoordinator.animateAlongsideTransition({(context: UIViewControllerTransitionCoordinatorContext!) -> Void in 51 | self.dimmingView.alpha = 0.0 52 | }, completion:nil) 53 | } 54 | } 55 | 56 | override func dismissalTransitionDidEnd(completed: Bool) { 57 | // If the dismissal completed, remove the dimming view 58 | if completed { 59 | self.dimmingView.removeFromSuperview() 60 | } 61 | } 62 | 63 | override func frameOfPresentedViewInContainerView() -> CGRect { 64 | 65 | guard 66 | let containerView = containerView 67 | else { 68 | return CGRect() 69 | } 70 | 71 | // We don't want the presented view to fill the whole container view, so inset it's frame 72 | var frame = containerView.bounds; 73 | frame = CGRectInset(frame, 50.0, 50.0) 74 | 75 | return frame 76 | } 77 | 78 | 79 | // ---- UIContentContainer protocol methods 80 | 81 | override func viewWillTransitionToSize(size: CGSize, withTransitionCoordinator transitionCoordinator: UIViewControllerTransitionCoordinator) { 82 | super.viewWillTransitionToSize(size, withTransitionCoordinator: transitionCoordinator) 83 | 84 | guard 85 | let containerView = containerView 86 | else { 87 | return 88 | } 89 | 90 | transitionCoordinator.animateAlongsideTransition({(context: UIViewControllerTransitionCoordinatorContext!) -> Void in 91 | self.dimmingView.frame = containerView.bounds 92 | }, completion:nil) 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /App/PresentationControllers/Images.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" : "40x40", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "60x60", 16 | "scale" : "2x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /App/PresentationControllers/Images.xcassets/LaunchImage.launchimage/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "orientation" : "portrait", 5 | "idiom" : "iphone", 6 | "extent" : "full-screen", 7 | "minimum-system-version" : "7.0", 8 | "scale" : "2x" 9 | }, 10 | { 11 | "orientation" : "portrait", 12 | "idiom" : "iphone", 13 | "subtype" : "retina4", 14 | "extent" : "full-screen", 15 | "minimum-system-version" : "7.0", 16 | "scale" : "2x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /App/PresentationControllers/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 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /App/PresentationControllers/MessageViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Pete Callaway on 26/06/2014. 3 | // Copyright (c) 2014 Dative Studios. All rights reserved. 4 | // 5 | 6 | import UIKit 7 | 8 | 9 | class MessageViewController: UIViewController, UIViewControllerTransitioningDelegate { 10 | required init?(coder aDecoder: NSCoder) { 11 | super.init(coder: aDecoder) 12 | self.commonInit() 13 | } 14 | 15 | override init(nibName nibNameOrNil: String!, bundle nibBundleOrNil: NSBundle!) { 16 | super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil) 17 | 18 | self.commonInit() 19 | } 20 | 21 | func commonInit() { 22 | self.modalPresentationStyle = .Custom 23 | self.transitioningDelegate = self 24 | } 25 | 26 | 27 | // ---- UIViewControllerTransitioningDelegate methods 28 | 29 | func presentationControllerForPresentedViewController(presented: UIViewController, presentingViewController presenting: UIViewController, sourceViewController source: UIViewController) -> UIPresentationController? { 30 | 31 | if presented == self { 32 | return CustomPresentationController(presentedViewController: presented, presentingViewController: presenting) 33 | } 34 | 35 | return nil 36 | } 37 | 38 | func animationControllerForPresentedController(presented: UIViewController, presentingController presenting: UIViewController, sourceController source: UIViewController) -> UIViewControllerAnimatedTransitioning? { 39 | 40 | if presented == self { 41 | return CustomPresentationAnimationController(isPresenting: true) 42 | } 43 | else { 44 | return nil 45 | } 46 | } 47 | 48 | func animationControllerForDismissedController(dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? { 49 | 50 | if dismissed == self { 51 | return CustomPresentationAnimationController(isPresenting: false) 52 | } 53 | else { 54 | return nil 55 | } 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /App/PresentationControllers/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Pete Callaway on 26/06/2014. 3 | // Copyright (c) 2014 Dative Studios. All rights reserved. 4 | // 5 | 6 | import UIKit 7 | 8 | class ViewController: UIViewController { 9 | 10 | @IBAction func dismiss(segue: UIStoryboardSegue) { 11 | self.dismissViewControllerAnimated(true, completion: nil) 12 | } 13 | } 14 | 15 | -------------------------------------------------------------------------------- /App/PresentationControllers/background.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PeteC/PresentationControllers/56447a9b3ed4ea57ec2b0eac2015f318588f0054/App/PresentationControllers/background.JPG -------------------------------------------------------------------------------- /App/PresentationControllersTests/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 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /App/PresentationControllersTests/PresentationControllersTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PresentationControllersTests.swift 3 | // PresentationControllersTests 4 | // 5 | // Created by Pete Callaway on 26/06/2014. 6 | // Copyright (c) 2014 Dative Studios. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | 11 | class PresentationControllersTests: XCTestCase { 12 | 13 | override func setUp() { 14 | super.setUp() 15 | // Put setup code here. This method is called before the invocation of each test method in the class. 16 | } 17 | 18 | override func tearDown() { 19 | // Put teardown code here. This method is called after the invocation of each test method in the class. 20 | super.tearDown() 21 | } 22 | 23 | func testExample() { 24 | // This is an example of a functional test case. 25 | XCTAssert(true, "Pass") 26 | } 27 | 28 | func testPerformanceExample() { 29 | // This is an example of a performance test case. 30 | self.measureBlock() { 31 | // Put the code you want to measure the time of here. 32 | } 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Dative Studios Ltd 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. -------------------------------------------------------------------------------- /PresentationControllers.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PeteC/PresentationControllers/56447a9b3ed4ea57ec2b0eac2015f318588f0054/PresentationControllers.gif -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | PresentationControllers 2 | =============== 3 | 4 | A quick project to show how to use ```UIPresentationController``` to create a custom modal presentation. It accompanies [this blog post](http://dativestudios.com/blog/2014/06/29/presentation-controllers/). 5 | 6 | ![Sample](https://raw.githubusercontent.com/petec-wwdc-2014/PresentationControllers/master/PresentationControllers.gif) 7 | --------------------------------------------------------------------------------