├── .DS_Store ├── .gitattributes ├── LICENSE ├── README.md ├── SlideOverTutorial.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ ├── xcshareddata │ │ └── IDEWorkspaceChecks.plist │ └── xcuserdata │ │ └── aivars.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── aivars.xcuserdatad │ ├── xcdebugger │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ └── xcschememanagement.plist └── SlideOverTutorial ├── AppDelegate.swift ├── Assets.xcassets ├── AccentColor.colorset │ └── Contents.json ├── AppIcon.appiconset │ └── Contents.json └── Contents.json ├── Base.lproj ├── LaunchScreen.storyboard └── Main.storyboard ├── Info.plist ├── OverlayView.swift ├── OverlayView.xib ├── PresentationController.swift ├── SceneDelegate.swift └── ViewController.swift /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aivars/SlideOverTutorial/79f7baeede466e7e5482960c03b2bf2702365a46/.DS_Store -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Aivars 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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## PanGesture slide-in half modal Bottom Card for UIKit + Swift 2 | 3 | ### Video tutorial : https://youtu.be/cI3Bzmq4EgY 4 | Why it is here: I spent the whole day creating a slide-out half modal screen for one of the freelance projects and just had to create a tutorial about it. Partly because was asked when I shared the result on Instagram, but mostly for future self do not browse documentation and tutorials again a few months later :) 5 | 6 | * Works fine and tested on Xcode 11 & 12 7 | * Used UIKit, UIPresentationController, and GestureRecognizer to get this result. 8 | #### Documentation and tutorials: 9 | * UIPresentationController : https://developer.apple.com/documentation/uikit/uipresentationcontroller 10 | * raywenderlich tutorial: https://www.raywenderlich.com/3636807-uipresentationcontroller-tutorial-getting-started 11 | * PanGesture + Codable slider UI tutorial: https://medium.com/@sarinyaswift/pangesture-slidable-view-swift-5-6718517f94a8 12 | * Draggable modal view: https://www.youtube.com/watch?v=acPVLXQshYk&ab_channel=WilsonBalderrama 13 | 14 | ![IMG_6857F0B9AD60-1](https://user-images.githubusercontent.com/774359/92694234-6c1c9580-f34f-11ea-8fad-82a442f13f8d.jpeg) 15 | -------------------------------------------------------------------------------- /SlideOverTutorial.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 50; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 6064B65A2508C99D000000C1 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6064B6592508C99D000000C1 /* AppDelegate.swift */; }; 11 | 6064B65C2508C99D000000C1 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6064B65B2508C99D000000C1 /* SceneDelegate.swift */; }; 12 | 6064B65E2508C99D000000C1 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6064B65D2508C99D000000C1 /* ViewController.swift */; }; 13 | 6064B6612508C99D000000C1 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6064B65F2508C99D000000C1 /* Main.storyboard */; }; 14 | 6064B6632508C99F000000C1 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6064B6622508C99F000000C1 /* Assets.xcassets */; }; 15 | 6064B6662508C99F000000C1 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6064B6642508C99F000000C1 /* LaunchScreen.storyboard */; }; 16 | 6064B66E2508C9FE000000C1 /* PresentationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6064B66D2508C9FE000000C1 /* PresentationController.swift */; }; 17 | 6064B6702508CB6C000000C1 /* OverlayView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 6064B66F2508CB6C000000C1 /* OverlayView.xib */; }; 18 | 6064B6742508CD20000000C1 /* OverlayView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6064B6732508CD20000000C1 /* OverlayView.swift */; }; 19 | /* End PBXBuildFile section */ 20 | 21 | /* Begin PBXFileReference section */ 22 | 6064B6562508C99D000000C1 /* SlideOverTutorial.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SlideOverTutorial.app; sourceTree = BUILT_PRODUCTS_DIR; }; 23 | 6064B6592508C99D000000C1 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 24 | 6064B65B2508C99D000000C1 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; 25 | 6064B65D2508C99D000000C1 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 26 | 6064B6602508C99D000000C1 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 27 | 6064B6622508C99F000000C1 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 28 | 6064B6652508C99F000000C1 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 29 | 6064B6672508C99F000000C1 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 30 | 6064B66D2508C9FE000000C1 /* PresentationController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PresentationController.swift; sourceTree = ""; }; 31 | 6064B66F2508CB6C000000C1 /* OverlayView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = OverlayView.xib; sourceTree = ""; }; 32 | 6064B6732508CD20000000C1 /* OverlayView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OverlayView.swift; sourceTree = ""; }; 33 | /* End PBXFileReference section */ 34 | 35 | /* Begin PBXFrameworksBuildPhase section */ 36 | 6064B6532508C99D000000C1 /* Frameworks */ = { 37 | isa = PBXFrameworksBuildPhase; 38 | buildActionMask = 2147483647; 39 | files = ( 40 | ); 41 | runOnlyForDeploymentPostprocessing = 0; 42 | }; 43 | /* End PBXFrameworksBuildPhase section */ 44 | 45 | /* Begin PBXGroup section */ 46 | 6064B64D2508C99D000000C1 = { 47 | isa = PBXGroup; 48 | children = ( 49 | 6064B6582508C99D000000C1 /* SlideOverTutorial */, 50 | 6064B6572508C99D000000C1 /* Products */, 51 | ); 52 | sourceTree = ""; 53 | }; 54 | 6064B6572508C99D000000C1 /* Products */ = { 55 | isa = PBXGroup; 56 | children = ( 57 | 6064B6562508C99D000000C1 /* SlideOverTutorial.app */, 58 | ); 59 | name = Products; 60 | sourceTree = ""; 61 | }; 62 | 6064B6582508C99D000000C1 /* SlideOverTutorial */ = { 63 | isa = PBXGroup; 64 | children = ( 65 | 6064B6592508C99D000000C1 /* AppDelegate.swift */, 66 | 6064B65B2508C99D000000C1 /* SceneDelegate.swift */, 67 | 6064B65D2508C99D000000C1 /* ViewController.swift */, 68 | 6064B65F2508C99D000000C1 /* Main.storyboard */, 69 | 6064B66D2508C9FE000000C1 /* PresentationController.swift */, 70 | 6064B66F2508CB6C000000C1 /* OverlayView.xib */, 71 | 6064B6732508CD20000000C1 /* OverlayView.swift */, 72 | 6064B6622508C99F000000C1 /* Assets.xcassets */, 73 | 6064B6642508C99F000000C1 /* LaunchScreen.storyboard */, 74 | 6064B6672508C99F000000C1 /* Info.plist */, 75 | ); 76 | path = SlideOverTutorial; 77 | sourceTree = ""; 78 | }; 79 | /* End PBXGroup section */ 80 | 81 | /* Begin PBXNativeTarget section */ 82 | 6064B6552508C99D000000C1 /* SlideOverTutorial */ = { 83 | isa = PBXNativeTarget; 84 | buildConfigurationList = 6064B66A2508C99F000000C1 /* Build configuration list for PBXNativeTarget "SlideOverTutorial" */; 85 | buildPhases = ( 86 | 6064B6522508C99D000000C1 /* Sources */, 87 | 6064B6532508C99D000000C1 /* Frameworks */, 88 | 6064B6542508C99D000000C1 /* Resources */, 89 | ); 90 | buildRules = ( 91 | ); 92 | dependencies = ( 93 | ); 94 | name = SlideOverTutorial; 95 | productName = SlideOverTutorial; 96 | productReference = 6064B6562508C99D000000C1 /* SlideOverTutorial.app */; 97 | productType = "com.apple.product-type.application"; 98 | }; 99 | /* End PBXNativeTarget section */ 100 | 101 | /* Begin PBXProject section */ 102 | 6064B64E2508C99D000000C1 /* Project object */ = { 103 | isa = PBXProject; 104 | attributes = { 105 | LastSwiftUpdateCheck = 1200; 106 | LastUpgradeCheck = 1200; 107 | TargetAttributes = { 108 | 6064B6552508C99D000000C1 = { 109 | CreatedOnToolsVersion = 12.0; 110 | }; 111 | }; 112 | }; 113 | buildConfigurationList = 6064B6512508C99D000000C1 /* Build configuration list for PBXProject "SlideOverTutorial" */; 114 | compatibilityVersion = "Xcode 9.3"; 115 | developmentRegion = en; 116 | hasScannedForEncodings = 0; 117 | knownRegions = ( 118 | en, 119 | Base, 120 | ); 121 | mainGroup = 6064B64D2508C99D000000C1; 122 | productRefGroup = 6064B6572508C99D000000C1 /* Products */; 123 | projectDirPath = ""; 124 | projectRoot = ""; 125 | targets = ( 126 | 6064B6552508C99D000000C1 /* SlideOverTutorial */, 127 | ); 128 | }; 129 | /* End PBXProject section */ 130 | 131 | /* Begin PBXResourcesBuildPhase section */ 132 | 6064B6542508C99D000000C1 /* Resources */ = { 133 | isa = PBXResourcesBuildPhase; 134 | buildActionMask = 2147483647; 135 | files = ( 136 | 6064B6662508C99F000000C1 /* LaunchScreen.storyboard in Resources */, 137 | 6064B6702508CB6C000000C1 /* OverlayView.xib in Resources */, 138 | 6064B6632508C99F000000C1 /* Assets.xcassets in Resources */, 139 | 6064B6612508C99D000000C1 /* Main.storyboard in Resources */, 140 | ); 141 | runOnlyForDeploymentPostprocessing = 0; 142 | }; 143 | /* End PBXResourcesBuildPhase section */ 144 | 145 | /* Begin PBXSourcesBuildPhase section */ 146 | 6064B6522508C99D000000C1 /* Sources */ = { 147 | isa = PBXSourcesBuildPhase; 148 | buildActionMask = 2147483647; 149 | files = ( 150 | 6064B65E2508C99D000000C1 /* ViewController.swift in Sources */, 151 | 6064B65A2508C99D000000C1 /* AppDelegate.swift in Sources */, 152 | 6064B65C2508C99D000000C1 /* SceneDelegate.swift in Sources */, 153 | 6064B66E2508C9FE000000C1 /* PresentationController.swift in Sources */, 154 | 6064B6742508CD20000000C1 /* OverlayView.swift in Sources */, 155 | ); 156 | runOnlyForDeploymentPostprocessing = 0; 157 | }; 158 | /* End PBXSourcesBuildPhase section */ 159 | 160 | /* Begin PBXVariantGroup section */ 161 | 6064B65F2508C99D000000C1 /* Main.storyboard */ = { 162 | isa = PBXVariantGroup; 163 | children = ( 164 | 6064B6602508C99D000000C1 /* Base */, 165 | ); 166 | name = Main.storyboard; 167 | sourceTree = ""; 168 | }; 169 | 6064B6642508C99F000000C1 /* LaunchScreen.storyboard */ = { 170 | isa = PBXVariantGroup; 171 | children = ( 172 | 6064B6652508C99F000000C1 /* Base */, 173 | ); 174 | name = LaunchScreen.storyboard; 175 | sourceTree = ""; 176 | }; 177 | /* End PBXVariantGroup section */ 178 | 179 | /* Begin XCBuildConfiguration section */ 180 | 6064B6682508C99F000000C1 /* Debug */ = { 181 | isa = XCBuildConfiguration; 182 | buildSettings = { 183 | ALWAYS_SEARCH_USER_PATHS = NO; 184 | CLANG_ANALYZER_NONNULL = YES; 185 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 186 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 187 | CLANG_CXX_LIBRARY = "libc++"; 188 | CLANG_ENABLE_MODULES = YES; 189 | CLANG_ENABLE_OBJC_ARC = YES; 190 | CLANG_ENABLE_OBJC_WEAK = YES; 191 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 192 | CLANG_WARN_BOOL_CONVERSION = YES; 193 | CLANG_WARN_COMMA = YES; 194 | CLANG_WARN_CONSTANT_CONVERSION = YES; 195 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 196 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 197 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 198 | CLANG_WARN_EMPTY_BODY = YES; 199 | CLANG_WARN_ENUM_CONVERSION = YES; 200 | CLANG_WARN_INFINITE_RECURSION = YES; 201 | CLANG_WARN_INT_CONVERSION = YES; 202 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 203 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 204 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 205 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 206 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 207 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 208 | CLANG_WARN_STRICT_PROTOTYPES = YES; 209 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 210 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 211 | CLANG_WARN_UNREACHABLE_CODE = YES; 212 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 213 | COPY_PHASE_STRIP = NO; 214 | DEBUG_INFORMATION_FORMAT = dwarf; 215 | ENABLE_STRICT_OBJC_MSGSEND = YES; 216 | ENABLE_TESTABILITY = YES; 217 | GCC_C_LANGUAGE_STANDARD = gnu11; 218 | GCC_DYNAMIC_NO_PIC = NO; 219 | GCC_NO_COMMON_BLOCKS = YES; 220 | GCC_OPTIMIZATION_LEVEL = 0; 221 | GCC_PREPROCESSOR_DEFINITIONS = ( 222 | "DEBUG=1", 223 | "$(inherited)", 224 | ); 225 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 226 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 227 | GCC_WARN_UNDECLARED_SELECTOR = YES; 228 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 229 | GCC_WARN_UNUSED_FUNCTION = YES; 230 | GCC_WARN_UNUSED_VARIABLE = YES; 231 | IPHONEOS_DEPLOYMENT_TARGET = 14.0; 232 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 233 | MTL_FAST_MATH = YES; 234 | ONLY_ACTIVE_ARCH = YES; 235 | SDKROOT = iphoneos; 236 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 237 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 238 | }; 239 | name = Debug; 240 | }; 241 | 6064B6692508C99F000000C1 /* Release */ = { 242 | isa = XCBuildConfiguration; 243 | buildSettings = { 244 | ALWAYS_SEARCH_USER_PATHS = NO; 245 | CLANG_ANALYZER_NONNULL = YES; 246 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 247 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 248 | CLANG_CXX_LIBRARY = "libc++"; 249 | CLANG_ENABLE_MODULES = YES; 250 | CLANG_ENABLE_OBJC_ARC = YES; 251 | CLANG_ENABLE_OBJC_WEAK = YES; 252 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 253 | CLANG_WARN_BOOL_CONVERSION = YES; 254 | CLANG_WARN_COMMA = YES; 255 | CLANG_WARN_CONSTANT_CONVERSION = YES; 256 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 257 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 258 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 259 | CLANG_WARN_EMPTY_BODY = YES; 260 | CLANG_WARN_ENUM_CONVERSION = YES; 261 | CLANG_WARN_INFINITE_RECURSION = YES; 262 | CLANG_WARN_INT_CONVERSION = YES; 263 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 264 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 265 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 266 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 267 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 268 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 269 | CLANG_WARN_STRICT_PROTOTYPES = YES; 270 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 271 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 272 | CLANG_WARN_UNREACHABLE_CODE = YES; 273 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 274 | COPY_PHASE_STRIP = NO; 275 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 276 | ENABLE_NS_ASSERTIONS = NO; 277 | ENABLE_STRICT_OBJC_MSGSEND = YES; 278 | GCC_C_LANGUAGE_STANDARD = gnu11; 279 | GCC_NO_COMMON_BLOCKS = YES; 280 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 281 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 282 | GCC_WARN_UNDECLARED_SELECTOR = YES; 283 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 284 | GCC_WARN_UNUSED_FUNCTION = YES; 285 | GCC_WARN_UNUSED_VARIABLE = YES; 286 | IPHONEOS_DEPLOYMENT_TARGET = 14.0; 287 | MTL_ENABLE_DEBUG_INFO = NO; 288 | MTL_FAST_MATH = YES; 289 | SDKROOT = iphoneos; 290 | SWIFT_COMPILATION_MODE = wholemodule; 291 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 292 | VALIDATE_PRODUCT = YES; 293 | }; 294 | name = Release; 295 | }; 296 | 6064B66B2508C99F000000C1 /* Debug */ = { 297 | isa = XCBuildConfiguration; 298 | buildSettings = { 299 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 300 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 301 | CODE_SIGN_STYLE = Automatic; 302 | DEVELOPMENT_TEAM = UDP9QHRJQB; 303 | INFOPLIST_FILE = SlideOverTutorial/Info.plist; 304 | LD_RUNPATH_SEARCH_PATHS = ( 305 | "$(inherited)", 306 | "@executable_path/Frameworks", 307 | ); 308 | PRODUCT_BUNDLE_IDENTIFIER = com.aivarsmeijers.SlideOverTutorial; 309 | PRODUCT_NAME = "$(TARGET_NAME)"; 310 | SWIFT_VERSION = 5.0; 311 | TARGETED_DEVICE_FAMILY = "1,2"; 312 | }; 313 | name = Debug; 314 | }; 315 | 6064B66C2508C99F000000C1 /* Release */ = { 316 | isa = XCBuildConfiguration; 317 | buildSettings = { 318 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 319 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 320 | CODE_SIGN_STYLE = Automatic; 321 | DEVELOPMENT_TEAM = UDP9QHRJQB; 322 | INFOPLIST_FILE = SlideOverTutorial/Info.plist; 323 | LD_RUNPATH_SEARCH_PATHS = ( 324 | "$(inherited)", 325 | "@executable_path/Frameworks", 326 | ); 327 | PRODUCT_BUNDLE_IDENTIFIER = com.aivarsmeijers.SlideOverTutorial; 328 | PRODUCT_NAME = "$(TARGET_NAME)"; 329 | SWIFT_VERSION = 5.0; 330 | TARGETED_DEVICE_FAMILY = "1,2"; 331 | }; 332 | name = Release; 333 | }; 334 | /* End XCBuildConfiguration section */ 335 | 336 | /* Begin XCConfigurationList section */ 337 | 6064B6512508C99D000000C1 /* Build configuration list for PBXProject "SlideOverTutorial" */ = { 338 | isa = XCConfigurationList; 339 | buildConfigurations = ( 340 | 6064B6682508C99F000000C1 /* Debug */, 341 | 6064B6692508C99F000000C1 /* Release */, 342 | ); 343 | defaultConfigurationIsVisible = 0; 344 | defaultConfigurationName = Release; 345 | }; 346 | 6064B66A2508C99F000000C1 /* Build configuration list for PBXNativeTarget "SlideOverTutorial" */ = { 347 | isa = XCConfigurationList; 348 | buildConfigurations = ( 349 | 6064B66B2508C99F000000C1 /* Debug */, 350 | 6064B66C2508C99F000000C1 /* Release */, 351 | ); 352 | defaultConfigurationIsVisible = 0; 353 | defaultConfigurationName = Release; 354 | }; 355 | /* End XCConfigurationList section */ 356 | }; 357 | rootObject = 6064B64E2508C99D000000C1 /* Project object */; 358 | } 359 | -------------------------------------------------------------------------------- /SlideOverTutorial.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /SlideOverTutorial.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /SlideOverTutorial.xcodeproj/project.xcworkspace/xcuserdata/aivars.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aivars/SlideOverTutorial/79f7baeede466e7e5482960c03b2bf2702365a46/SlideOverTutorial.xcodeproj/project.xcworkspace/xcuserdata/aivars.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /SlideOverTutorial.xcodeproj/xcuserdata/aivars.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 9 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /SlideOverTutorial.xcodeproj/xcuserdata/aivars.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | SlideOverTutorial.xcscheme_^#shared#^_ 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /SlideOverTutorial/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // SlideOverTutorial 4 | // 5 | // Created by Aivars Meijers on 09/09/2020. 6 | // 7 | 8 | import UIKit 9 | 10 | @main 11 | class AppDelegate: UIResponder, UIApplicationDelegate { 12 | 13 | 14 | 15 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 16 | // Override point for customization after application launch. 17 | return true 18 | } 19 | 20 | // MARK: UISceneSession Lifecycle 21 | 22 | func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { 23 | // Called when a new scene session is being created. 24 | // Use this method to select a configuration to create the new scene with. 25 | return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) 26 | } 27 | 28 | func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set) { 29 | // Called when the user discards a scene session. 30 | // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. 31 | // Use this method to release any resources that were specific to the discarded scenes, as they will not return. 32 | } 33 | 34 | 35 | } 36 | 37 | -------------------------------------------------------------------------------- /SlideOverTutorial/Assets.xcassets/AccentColor.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "idiom" : "universal" 5 | } 6 | ], 7 | "info" : { 8 | "author" : "xcode", 9 | "version" : 1 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /SlideOverTutorial/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "scale" : "2x", 6 | "size" : "20x20" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "scale" : "3x", 11 | "size" : "20x20" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "scale" : "2x", 16 | "size" : "29x29" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "scale" : "3x", 21 | "size" : "29x29" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "scale" : "2x", 26 | "size" : "40x40" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "scale" : "3x", 31 | "size" : "40x40" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "scale" : "2x", 36 | "size" : "60x60" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "scale" : "3x", 41 | "size" : "60x60" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "scale" : "1x", 46 | "size" : "20x20" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "scale" : "2x", 51 | "size" : "20x20" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "scale" : "1x", 56 | "size" : "29x29" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "scale" : "2x", 61 | "size" : "29x29" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "scale" : "1x", 66 | "size" : "40x40" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "scale" : "2x", 71 | "size" : "40x40" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "scale" : "1x", 76 | "size" : "76x76" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "scale" : "2x", 81 | "size" : "76x76" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "scale" : "2x", 86 | "size" : "83.5x83.5" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "scale" : "1x", 91 | "size" : "1024x1024" 92 | } 93 | ], 94 | "info" : { 95 | "author" : "xcode", 96 | "version" : 1 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /SlideOverTutorial/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /SlideOverTutorial/Base.lproj/LaunchScreen.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 | -------------------------------------------------------------------------------- /SlideOverTutorial/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /SlideOverTutorial/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UIApplicationSceneManifest 24 | 25 | UIApplicationSupportsMultipleScenes 26 | 27 | UISceneConfigurations 28 | 29 | UIWindowSceneSessionRoleApplication 30 | 31 | 32 | UISceneConfigurationName 33 | Default Configuration 34 | UISceneDelegateClassName 35 | $(PRODUCT_MODULE_NAME).SceneDelegate 36 | UISceneStoryboardFile 37 | Main 38 | 39 | 40 | 41 | 42 | UIApplicationSupportsIndirectInputEvents 43 | 44 | UILaunchStoryboardName 45 | LaunchScreen 46 | UIMainStoryboardFile 47 | Main 48 | UIRequiredDeviceCapabilities 49 | 50 | armv7 51 | 52 | UISupportedInterfaceOrientations 53 | 54 | UIInterfaceOrientationPortrait 55 | UIInterfaceOrientationLandscapeLeft 56 | UIInterfaceOrientationLandscapeRight 57 | 58 | UISupportedInterfaceOrientations~ipad 59 | 60 | UIInterfaceOrientationPortrait 61 | UIInterfaceOrientationPortraitUpsideDown 62 | UIInterfaceOrientationLandscapeLeft 63 | UIInterfaceOrientationLandscapeRight 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /SlideOverTutorial/OverlayView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // OverlayView.swift 3 | // SlideOverTutorial 4 | // 5 | // Created by Aivars Meijers on 09/09/2020. 6 | // 7 | 8 | import UIKit 9 | 10 | class OverlayView: UIViewController { 11 | 12 | var hasSetPointOrigin = false 13 | var pointOrigin: CGPoint? 14 | 15 | @IBOutlet weak var slideIdicator: UIView! 16 | @IBOutlet weak var imageView: UIImageView! 17 | @IBOutlet weak var subscribeButton: UIView! 18 | 19 | override func viewDidLoad() { 20 | super.viewDidLoad() 21 | let panGesture = UIPanGestureRecognizer(target: self, action: #selector(panGestureRecognizerAction)) 22 | view.addGestureRecognizer(panGesture) 23 | 24 | slideIdicator.roundCorners(.allCorners, radius: 10) 25 | subscribeButton.roundCorners(.allCorners, radius: 10) 26 | } 27 | 28 | override func viewDidLayoutSubviews() { 29 | if !hasSetPointOrigin { 30 | hasSetPointOrigin = true 31 | pointOrigin = self.view.frame.origin 32 | } 33 | } 34 | @objc func panGestureRecognizerAction(sender: UIPanGestureRecognizer) { 35 | let translation = sender.translation(in: view) 36 | 37 | // Not allowing the user to drag the view upward 38 | guard translation.y >= 0 else { return } 39 | 40 | // setting x as 0 because we don't want users to move the frame side ways!! Only want straight up or down 41 | view.frame.origin = CGPoint(x: 0, y: self.pointOrigin!.y + translation.y) 42 | 43 | if sender.state == .ended { 44 | let draggedToDismiss = (translation.y > view.frame.size.height/3.0) 45 | let dragVelocity = sender.velocity(in: view) 46 | if (dragVelocity.y >= 1300) || draggedToDismiss { 47 | self.dismiss(animated: true, completion: nil) 48 | } else { 49 | // Set back to original position of the view controller 50 | UIView.animate(withDuration: 0.3) { 51 | self.view.frame.origin = self.pointOrigin ?? CGPoint(x: 0, y: 400) 52 | } 53 | } 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /SlideOverTutorial/OverlayView.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 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 | -------------------------------------------------------------------------------- /SlideOverTutorial/PresentationController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PresentationController.swift 3 | // SlideOverTutorial 4 | // 5 | // Created by Aivars Meijers on 09/09/2020. 6 | // 7 | 8 | 9 | import UIKit 10 | 11 | class PresentationController: UIPresentationController { 12 | 13 | let blurEffectView: UIVisualEffectView! 14 | var tapGestureRecognizer: UITapGestureRecognizer = UITapGestureRecognizer() 15 | 16 | override init(presentedViewController: UIViewController, presenting presentingViewController: UIViewController?) { 17 | let blurEffect = UIBlurEffect(style: .dark) 18 | blurEffectView = UIVisualEffectView(effect: blurEffect) 19 | super.init(presentedViewController: presentedViewController, presenting: presentingViewController) 20 | tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(dismissController)) 21 | blurEffectView.autoresizingMask = [.flexibleWidth, .flexibleHeight] 22 | self.blurEffectView.isUserInteractionEnabled = true 23 | self.blurEffectView.addGestureRecognizer(tapGestureRecognizer) 24 | } 25 | 26 | override var frameOfPresentedViewInContainerView: CGRect { 27 | CGRect(origin: CGPoint(x: 0, y: self.containerView!.frame.height * 0.4), 28 | size: CGSize(width: self.containerView!.frame.width, height: self.containerView!.frame.height * 29 | 0.6)) 30 | } 31 | 32 | override func presentationTransitionWillBegin() { 33 | self.blurEffectView.alpha = 0 34 | self.containerView?.addSubview(blurEffectView) 35 | self.presentedViewController.transitionCoordinator?.animate(alongsideTransition: { (UIViewControllerTransitionCoordinatorContext) in 36 | self.blurEffectView.alpha = 0.7 37 | }, completion: { (UIViewControllerTransitionCoordinatorContext) in }) 38 | } 39 | 40 | override func dismissalTransitionWillBegin() { 41 | self.presentedViewController.transitionCoordinator?.animate(alongsideTransition: { (UIViewControllerTransitionCoordinatorContext) in 42 | self.blurEffectView.alpha = 0 43 | }, completion: { (UIViewControllerTransitionCoordinatorContext) in 44 | self.blurEffectView.removeFromSuperview() 45 | }) 46 | } 47 | 48 | override func containerViewWillLayoutSubviews() { 49 | super.containerViewWillLayoutSubviews() 50 | presentedView!.roundCorners([.topLeft, .topRight], radius: 22) 51 | } 52 | 53 | override func containerViewDidLayoutSubviews() { 54 | super.containerViewDidLayoutSubviews() 55 | presentedView?.frame = frameOfPresentedViewInContainerView 56 | blurEffectView.frame = containerView!.bounds 57 | } 58 | 59 | @objc func dismissController(){ 60 | self.presentedViewController.dismiss(animated: true, completion: nil) 61 | } 62 | } 63 | 64 | extension UIView { 65 | func roundCorners(_ corners: UIRectCorner, radius: CGFloat) { 66 | let path = UIBezierPath(roundedRect: bounds, byRoundingCorners: corners, 67 | cornerRadii: CGSize(width: radius, height: radius)) 68 | let mask = CAShapeLayer() 69 | mask.path = path.cgPath 70 | layer.mask = mask 71 | } 72 | } 73 | 74 | -------------------------------------------------------------------------------- /SlideOverTutorial/SceneDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SceneDelegate.swift 3 | // SlideOverTutorial 4 | // 5 | // Created by Aivars Meijers on 09/09/2020. 6 | // 7 | 8 | import UIKit 9 | 10 | class SceneDelegate: UIResponder, UIWindowSceneDelegate { 11 | 12 | var window: UIWindow? 13 | 14 | 15 | func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { 16 | // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. 17 | // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. 18 | // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). 19 | guard let _ = (scene as? UIWindowScene) else { return } 20 | } 21 | 22 | func sceneDidDisconnect(_ scene: UIScene) { 23 | // Called as the scene is being released by the system. 24 | // This occurs shortly after the scene enters the background, or when its session is discarded. 25 | // Release any resources associated with this scene that can be re-created the next time the scene connects. 26 | // The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead). 27 | } 28 | 29 | func sceneDidBecomeActive(_ scene: UIScene) { 30 | // Called when the scene has moved from an inactive state to an active state. 31 | // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. 32 | } 33 | 34 | func sceneWillResignActive(_ scene: UIScene) { 35 | // Called when the scene will move from an active state to an inactive state. 36 | // This may occur due to temporary interruptions (ex. an incoming phone call). 37 | } 38 | 39 | func sceneWillEnterForeground(_ scene: UIScene) { 40 | // Called as the scene transitions from the background to the foreground. 41 | // Use this method to undo the changes made on entering the background. 42 | } 43 | 44 | func sceneDidEnterBackground(_ scene: UIScene) { 45 | // Called as the scene transitions from the foreground to the background. 46 | // Use this method to save data, release shared resources, and store enough scene-specific state information 47 | // to restore the scene back to its current state. 48 | } 49 | 50 | 51 | } 52 | 53 | -------------------------------------------------------------------------------- /SlideOverTutorial/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // SlideOverTutorial 4 | // 5 | // Created by Aivars Meijers on 09/09/2020. 6 | // 7 | 8 | import UIKit 9 | 10 | class ViewController: UIViewController { 11 | 12 | override func viewDidLoad() { 13 | super.viewDidLoad() 14 | // Do any additional setup after loading the view. 15 | } 16 | 17 | @objc func showMiracle() { 18 | let slideVC = OverlayView() 19 | slideVC.modalPresentationStyle = .custom 20 | slideVC.transitioningDelegate = self 21 | self.present(slideVC, animated: true, completion: nil) 22 | } 23 | 24 | @IBAction func onButton(_ sender: Any) { 25 | showMiracle() 26 | } 27 | 28 | } 29 | 30 | extension ViewController: UIViewControllerTransitioningDelegate { 31 | func presentationController(forPresented presented: UIViewController, presenting: UIViewController?, source: UIViewController) -> UIPresentationController? { 32 | PresentationController(presentedViewController: presented, presenting: presenting) 33 | } 34 | } 35 | --------------------------------------------------------------------------------