├── .gitignore ├── AppleMusicTransition.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── AppleMusicTransition ├── Animator │ ├── AMPresentInteractiveAnimator.swift │ └── AMPresentationController.swift ├── AppDelegate.swift ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ ├── Contents.json │ └── cover.imageset │ │ ├── Contents.json │ │ └── cover.jpg ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Const.swift ├── Controller │ ├── MusicDetailViewController.swift │ └── TabBarViewController.swift ├── Info.plist └── View │ └── PlayBarView.swift ├── AppleMusicTransitionTests ├── AppleMusicTransitionTests.swift └── Info.plist ├── README.md └── sample.gif /.gitignore: -------------------------------------------------------------------------------- 1 | ## Build generated 2 | build/ 3 | DerivedData/ 4 | 5 | ## Various settings 6 | *.pbxuser 7 | !default.pbxuser 8 | *.mode1v3 9 | !default.mode1v3 10 | *.mode2v3 11 | !default.mode2v3 12 | *.perspectivev3 13 | !default.perspectivev3 14 | xcuserdata/ 15 | 16 | ## Other 17 | *.moved-aside 18 | *.xccheckout 19 | *.xcscmblueprint 20 | 21 | ## Obj-C/Swift specific 22 | *.hmap 23 | *.ipa 24 | *.dSYM.zip 25 | *.dSYM 26 | -------------------------------------------------------------------------------- /AppleMusicTransition.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 48; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 4CFB10CA204F7A0F0053C27C /* Const.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CFB10C9204F7A0F0053C27C /* Const.swift */; }; 11 | 4CFB10CE204F963A0053C27C /* AMPresentInteractiveAnimator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CFB10CD204F963A0053C27C /* AMPresentInteractiveAnimator.swift */; }; 12 | 76774FCF204D7176008B6F3D /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 76774FCE204D7176008B6F3D /* AppDelegate.swift */; }; 13 | 76774FD4204D7176008B6F3D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 76774FD2204D7176008B6F3D /* Main.storyboard */; }; 14 | 76774FD6204D7176008B6F3D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 76774FD5204D7176008B6F3D /* Assets.xcassets */; }; 15 | 76774FD9204D7176008B6F3D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 76774FD7204D7176008B6F3D /* LaunchScreen.storyboard */; }; 16 | 76774FE4204D7176008B6F3D /* AppleMusicTransitionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 76774FE3204D7176008B6F3D /* AppleMusicTransitionTests.swift */; }; 17 | 76774FEF204D739F008B6F3D /* TabBarViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 76774FEE204D739F008B6F3D /* TabBarViewController.swift */; }; 18 | 76774FF2204D78DD008B6F3D /* PlayBarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 76774FF1204D78DD008B6F3D /* PlayBarView.swift */; }; 19 | 76774FF7204D84AB008B6F3D /* MusicDetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 76774FF6204D84AB008B6F3D /* MusicDetailViewController.swift */; }; 20 | 76774FF9204D96FB008B6F3D /* AMPresentationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 76774FF8204D96FB008B6F3D /* AMPresentationController.swift */; }; 21 | /* End PBXBuildFile section */ 22 | 23 | /* Begin PBXContainerItemProxy section */ 24 | 76774FE0204D7176008B6F3D /* PBXContainerItemProxy */ = { 25 | isa = PBXContainerItemProxy; 26 | containerPortal = 76774FC3204D7176008B6F3D /* Project object */; 27 | proxyType = 1; 28 | remoteGlobalIDString = 76774FCA204D7176008B6F3D; 29 | remoteInfo = AppleMusicTransition; 30 | }; 31 | /* End PBXContainerItemProxy section */ 32 | 33 | /* Begin PBXFileReference section */ 34 | 4CFB10C9204F7A0F0053C27C /* Const.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Const.swift; sourceTree = ""; }; 35 | 4CFB10CD204F963A0053C27C /* AMPresentInteractiveAnimator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AMPresentInteractiveAnimator.swift; sourceTree = ""; }; 36 | 76774FCB204D7176008B6F3D /* AppleMusicTransition.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = AppleMusicTransition.app; sourceTree = BUILT_PRODUCTS_DIR; }; 37 | 76774FCE204D7176008B6F3D /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 38 | 76774FD3204D7176008B6F3D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 39 | 76774FD5204D7176008B6F3D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 40 | 76774FD8204D7176008B6F3D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 41 | 76774FDA204D7176008B6F3D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 42 | 76774FDF204D7176008B6F3D /* AppleMusicTransitionTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = AppleMusicTransitionTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 43 | 76774FE3204D7176008B6F3D /* AppleMusicTransitionTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppleMusicTransitionTests.swift; sourceTree = ""; }; 44 | 76774FE5204D7176008B6F3D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 45 | 76774FEE204D739F008B6F3D /* TabBarViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabBarViewController.swift; sourceTree = ""; }; 46 | 76774FF1204D78DD008B6F3D /* PlayBarView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayBarView.swift; sourceTree = ""; }; 47 | 76774FF6204D84AB008B6F3D /* MusicDetailViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MusicDetailViewController.swift; sourceTree = ""; }; 48 | 76774FF8204D96FB008B6F3D /* AMPresentationController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AMPresentationController.swift; sourceTree = ""; }; 49 | /* End PBXFileReference section */ 50 | 51 | /* Begin PBXFrameworksBuildPhase section */ 52 | 76774FC8204D7176008B6F3D /* Frameworks */ = { 53 | isa = PBXFrameworksBuildPhase; 54 | buildActionMask = 2147483647; 55 | files = ( 56 | ); 57 | runOnlyForDeploymentPostprocessing = 0; 58 | }; 59 | 76774FDC204D7176008B6F3D /* Frameworks */ = { 60 | isa = PBXFrameworksBuildPhase; 61 | buildActionMask = 2147483647; 62 | files = ( 63 | ); 64 | runOnlyForDeploymentPostprocessing = 0; 65 | }; 66 | /* End PBXFrameworksBuildPhase section */ 67 | 68 | /* Begin PBXGroup section */ 69 | 4CFB10C8204F791F0053C27C /* Controller */ = { 70 | isa = PBXGroup; 71 | children = ( 72 | 76774FEE204D739F008B6F3D /* TabBarViewController.swift */, 73 | 76774FF6204D84AB008B6F3D /* MusicDetailViewController.swift */, 74 | ); 75 | path = Controller; 76 | sourceTree = ""; 77 | }; 78 | 76774FC2204D7176008B6F3D = { 79 | isa = PBXGroup; 80 | children = ( 81 | 76774FCD204D7176008B6F3D /* AppleMusicTransition */, 82 | 76774FE2204D7176008B6F3D /* AppleMusicTransitionTests */, 83 | 76774FCC204D7176008B6F3D /* Products */, 84 | ); 85 | sourceTree = ""; 86 | }; 87 | 76774FCC204D7176008B6F3D /* Products */ = { 88 | isa = PBXGroup; 89 | children = ( 90 | 76774FCB204D7176008B6F3D /* AppleMusicTransition.app */, 91 | 76774FDF204D7176008B6F3D /* AppleMusicTransitionTests.xctest */, 92 | ); 93 | name = Products; 94 | sourceTree = ""; 95 | }; 96 | 76774FCD204D7176008B6F3D /* AppleMusicTransition */ = { 97 | isa = PBXGroup; 98 | children = ( 99 | 4CFB10C8204F791F0053C27C /* Controller */, 100 | 76774FF3204D8131008B6F3D /* Animator */, 101 | 76774FF0204D78CC008B6F3D /* View */, 102 | 76774FCE204D7176008B6F3D /* AppDelegate.swift */, 103 | 4CFB10C9204F7A0F0053C27C /* Const.swift */, 104 | 76774FD2204D7176008B6F3D /* Main.storyboard */, 105 | 76774FD5204D7176008B6F3D /* Assets.xcassets */, 106 | 76774FD7204D7176008B6F3D /* LaunchScreen.storyboard */, 107 | 76774FDA204D7176008B6F3D /* Info.plist */, 108 | ); 109 | path = AppleMusicTransition; 110 | sourceTree = ""; 111 | }; 112 | 76774FE2204D7176008B6F3D /* AppleMusicTransitionTests */ = { 113 | isa = PBXGroup; 114 | children = ( 115 | 76774FE3204D7176008B6F3D /* AppleMusicTransitionTests.swift */, 116 | 76774FE5204D7176008B6F3D /* Info.plist */, 117 | ); 118 | path = AppleMusicTransitionTests; 119 | sourceTree = ""; 120 | }; 121 | 76774FF0204D78CC008B6F3D /* View */ = { 122 | isa = PBXGroup; 123 | children = ( 124 | 76774FF1204D78DD008B6F3D /* PlayBarView.swift */, 125 | ); 126 | path = View; 127 | sourceTree = ""; 128 | }; 129 | 76774FF3204D8131008B6F3D /* Animator */ = { 130 | isa = PBXGroup; 131 | children = ( 132 | 76774FF8204D96FB008B6F3D /* AMPresentationController.swift */, 133 | 4CFB10CD204F963A0053C27C /* AMPresentInteractiveAnimator.swift */, 134 | ); 135 | path = Animator; 136 | sourceTree = ""; 137 | }; 138 | /* End PBXGroup section */ 139 | 140 | /* Begin PBXNativeTarget section */ 141 | 76774FCA204D7176008B6F3D /* AppleMusicTransition */ = { 142 | isa = PBXNativeTarget; 143 | buildConfigurationList = 76774FE8204D7176008B6F3D /* Build configuration list for PBXNativeTarget "AppleMusicTransition" */; 144 | buildPhases = ( 145 | 76774FC7204D7176008B6F3D /* Sources */, 146 | 76774FC8204D7176008B6F3D /* Frameworks */, 147 | 76774FC9204D7176008B6F3D /* Resources */, 148 | ); 149 | buildRules = ( 150 | ); 151 | dependencies = ( 152 | ); 153 | name = AppleMusicTransition; 154 | productName = AppleMusicTransition; 155 | productReference = 76774FCB204D7176008B6F3D /* AppleMusicTransition.app */; 156 | productType = "com.apple.product-type.application"; 157 | }; 158 | 76774FDE204D7176008B6F3D /* AppleMusicTransitionTests */ = { 159 | isa = PBXNativeTarget; 160 | buildConfigurationList = 76774FEB204D7176008B6F3D /* Build configuration list for PBXNativeTarget "AppleMusicTransitionTests" */; 161 | buildPhases = ( 162 | 76774FDB204D7176008B6F3D /* Sources */, 163 | 76774FDC204D7176008B6F3D /* Frameworks */, 164 | 76774FDD204D7176008B6F3D /* Resources */, 165 | ); 166 | buildRules = ( 167 | ); 168 | dependencies = ( 169 | 76774FE1204D7176008B6F3D /* PBXTargetDependency */, 170 | ); 171 | name = AppleMusicTransitionTests; 172 | productName = AppleMusicTransitionTests; 173 | productReference = 76774FDF204D7176008B6F3D /* AppleMusicTransitionTests.xctest */; 174 | productType = "com.apple.product-type.bundle.unit-test"; 175 | }; 176 | /* End PBXNativeTarget section */ 177 | 178 | /* Begin PBXProject section */ 179 | 76774FC3204D7176008B6F3D /* Project object */ = { 180 | isa = PBXProject; 181 | attributes = { 182 | LastSwiftUpdateCheck = 0920; 183 | LastUpgradeCheck = 0920; 184 | ORGANIZATIONNAME = cookie; 185 | TargetAttributes = { 186 | 76774FCA204D7176008B6F3D = { 187 | CreatedOnToolsVersion = 9.2; 188 | ProvisioningStyle = Automatic; 189 | }; 190 | 76774FDE204D7176008B6F3D = { 191 | CreatedOnToolsVersion = 9.2; 192 | ProvisioningStyle = Automatic; 193 | TestTargetID = 76774FCA204D7176008B6F3D; 194 | }; 195 | }; 196 | }; 197 | buildConfigurationList = 76774FC6204D7176008B6F3D /* Build configuration list for PBXProject "AppleMusicTransition" */; 198 | compatibilityVersion = "Xcode 8.0"; 199 | developmentRegion = en; 200 | hasScannedForEncodings = 0; 201 | knownRegions = ( 202 | en, 203 | Base, 204 | ); 205 | mainGroup = 76774FC2204D7176008B6F3D; 206 | productRefGroup = 76774FCC204D7176008B6F3D /* Products */; 207 | projectDirPath = ""; 208 | projectRoot = ""; 209 | targets = ( 210 | 76774FCA204D7176008B6F3D /* AppleMusicTransition */, 211 | 76774FDE204D7176008B6F3D /* AppleMusicTransitionTests */, 212 | ); 213 | }; 214 | /* End PBXProject section */ 215 | 216 | /* Begin PBXResourcesBuildPhase section */ 217 | 76774FC9204D7176008B6F3D /* Resources */ = { 218 | isa = PBXResourcesBuildPhase; 219 | buildActionMask = 2147483647; 220 | files = ( 221 | 76774FD9204D7176008B6F3D /* LaunchScreen.storyboard in Resources */, 222 | 76774FD6204D7176008B6F3D /* Assets.xcassets in Resources */, 223 | 76774FD4204D7176008B6F3D /* Main.storyboard in Resources */, 224 | ); 225 | runOnlyForDeploymentPostprocessing = 0; 226 | }; 227 | 76774FDD204D7176008B6F3D /* Resources */ = { 228 | isa = PBXResourcesBuildPhase; 229 | buildActionMask = 2147483647; 230 | files = ( 231 | ); 232 | runOnlyForDeploymentPostprocessing = 0; 233 | }; 234 | /* End PBXResourcesBuildPhase section */ 235 | 236 | /* Begin PBXSourcesBuildPhase section */ 237 | 76774FC7204D7176008B6F3D /* Sources */ = { 238 | isa = PBXSourcesBuildPhase; 239 | buildActionMask = 2147483647; 240 | files = ( 241 | 76774FEF204D739F008B6F3D /* TabBarViewController.swift in Sources */, 242 | 76774FF2204D78DD008B6F3D /* PlayBarView.swift in Sources */, 243 | 76774FCF204D7176008B6F3D /* AppDelegate.swift in Sources */, 244 | 4CFB10CE204F963A0053C27C /* AMPresentInteractiveAnimator.swift in Sources */, 245 | 76774FF7204D84AB008B6F3D /* MusicDetailViewController.swift in Sources */, 246 | 76774FF9204D96FB008B6F3D /* AMPresentationController.swift in Sources */, 247 | 4CFB10CA204F7A0F0053C27C /* Const.swift in Sources */, 248 | ); 249 | runOnlyForDeploymentPostprocessing = 0; 250 | }; 251 | 76774FDB204D7176008B6F3D /* Sources */ = { 252 | isa = PBXSourcesBuildPhase; 253 | buildActionMask = 2147483647; 254 | files = ( 255 | 76774FE4204D7176008B6F3D /* AppleMusicTransitionTests.swift in Sources */, 256 | ); 257 | runOnlyForDeploymentPostprocessing = 0; 258 | }; 259 | /* End PBXSourcesBuildPhase section */ 260 | 261 | /* Begin PBXTargetDependency section */ 262 | 76774FE1204D7176008B6F3D /* PBXTargetDependency */ = { 263 | isa = PBXTargetDependency; 264 | target = 76774FCA204D7176008B6F3D /* AppleMusicTransition */; 265 | targetProxy = 76774FE0204D7176008B6F3D /* PBXContainerItemProxy */; 266 | }; 267 | /* End PBXTargetDependency section */ 268 | 269 | /* Begin PBXVariantGroup section */ 270 | 76774FD2204D7176008B6F3D /* Main.storyboard */ = { 271 | isa = PBXVariantGroup; 272 | children = ( 273 | 76774FD3204D7176008B6F3D /* Base */, 274 | ); 275 | name = Main.storyboard; 276 | sourceTree = ""; 277 | }; 278 | 76774FD7204D7176008B6F3D /* LaunchScreen.storyboard */ = { 279 | isa = PBXVariantGroup; 280 | children = ( 281 | 76774FD8204D7176008B6F3D /* Base */, 282 | ); 283 | name = LaunchScreen.storyboard; 284 | sourceTree = ""; 285 | }; 286 | /* End PBXVariantGroup section */ 287 | 288 | /* Begin XCBuildConfiguration section */ 289 | 76774FE6204D7176008B6F3D /* Debug */ = { 290 | isa = XCBuildConfiguration; 291 | buildSettings = { 292 | ALWAYS_SEARCH_USER_PATHS = NO; 293 | CLANG_ANALYZER_NONNULL = YES; 294 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 295 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 296 | CLANG_CXX_LIBRARY = "libc++"; 297 | CLANG_ENABLE_MODULES = YES; 298 | CLANG_ENABLE_OBJC_ARC = YES; 299 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 300 | CLANG_WARN_BOOL_CONVERSION = YES; 301 | CLANG_WARN_COMMA = YES; 302 | CLANG_WARN_CONSTANT_CONVERSION = YES; 303 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 304 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 305 | CLANG_WARN_EMPTY_BODY = YES; 306 | CLANG_WARN_ENUM_CONVERSION = YES; 307 | CLANG_WARN_INFINITE_RECURSION = YES; 308 | CLANG_WARN_INT_CONVERSION = YES; 309 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 310 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 311 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 312 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 313 | CLANG_WARN_STRICT_PROTOTYPES = YES; 314 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 315 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 316 | CLANG_WARN_UNREACHABLE_CODE = YES; 317 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 318 | CODE_SIGN_IDENTITY = "iPhone Developer"; 319 | COPY_PHASE_STRIP = NO; 320 | DEBUG_INFORMATION_FORMAT = dwarf; 321 | ENABLE_STRICT_OBJC_MSGSEND = YES; 322 | ENABLE_TESTABILITY = YES; 323 | GCC_C_LANGUAGE_STANDARD = gnu11; 324 | GCC_DYNAMIC_NO_PIC = NO; 325 | GCC_NO_COMMON_BLOCKS = YES; 326 | GCC_OPTIMIZATION_LEVEL = 0; 327 | GCC_PREPROCESSOR_DEFINITIONS = ( 328 | "DEBUG=1", 329 | "$(inherited)", 330 | ); 331 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 332 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 333 | GCC_WARN_UNDECLARED_SELECTOR = YES; 334 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 335 | GCC_WARN_UNUSED_FUNCTION = YES; 336 | GCC_WARN_UNUSED_VARIABLE = YES; 337 | IPHONEOS_DEPLOYMENT_TARGET = 11.2; 338 | MTL_ENABLE_DEBUG_INFO = YES; 339 | ONLY_ACTIVE_ARCH = YES; 340 | SDKROOT = iphoneos; 341 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 342 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 343 | }; 344 | name = Debug; 345 | }; 346 | 76774FE7204D7176008B6F3D /* Release */ = { 347 | isa = XCBuildConfiguration; 348 | buildSettings = { 349 | ALWAYS_SEARCH_USER_PATHS = NO; 350 | CLANG_ANALYZER_NONNULL = YES; 351 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 352 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 353 | CLANG_CXX_LIBRARY = "libc++"; 354 | CLANG_ENABLE_MODULES = YES; 355 | CLANG_ENABLE_OBJC_ARC = YES; 356 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 357 | CLANG_WARN_BOOL_CONVERSION = YES; 358 | CLANG_WARN_COMMA = YES; 359 | CLANG_WARN_CONSTANT_CONVERSION = YES; 360 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 361 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 362 | CLANG_WARN_EMPTY_BODY = YES; 363 | CLANG_WARN_ENUM_CONVERSION = YES; 364 | CLANG_WARN_INFINITE_RECURSION = YES; 365 | CLANG_WARN_INT_CONVERSION = YES; 366 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 367 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 368 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 369 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 370 | CLANG_WARN_STRICT_PROTOTYPES = YES; 371 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 372 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 373 | CLANG_WARN_UNREACHABLE_CODE = YES; 374 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 375 | CODE_SIGN_IDENTITY = "iPhone Developer"; 376 | COPY_PHASE_STRIP = NO; 377 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 378 | ENABLE_NS_ASSERTIONS = NO; 379 | ENABLE_STRICT_OBJC_MSGSEND = YES; 380 | GCC_C_LANGUAGE_STANDARD = gnu11; 381 | GCC_NO_COMMON_BLOCKS = YES; 382 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 383 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 384 | GCC_WARN_UNDECLARED_SELECTOR = YES; 385 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 386 | GCC_WARN_UNUSED_FUNCTION = YES; 387 | GCC_WARN_UNUSED_VARIABLE = YES; 388 | IPHONEOS_DEPLOYMENT_TARGET = 11.2; 389 | MTL_ENABLE_DEBUG_INFO = NO; 390 | SDKROOT = iphoneos; 391 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 392 | VALIDATE_PRODUCT = YES; 393 | }; 394 | name = Release; 395 | }; 396 | 76774FE9204D7176008B6F3D /* Debug */ = { 397 | isa = XCBuildConfiguration; 398 | buildSettings = { 399 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 400 | CODE_SIGN_STYLE = Automatic; 401 | DEVELOPMENT_TEAM = 2RNKT55WYW; 402 | INFOPLIST_FILE = AppleMusicTransition/Info.plist; 403 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 404 | PRODUCT_BUNDLE_IDENTIFIER = zby.AppleMusicTransition; 405 | PRODUCT_NAME = "$(TARGET_NAME)"; 406 | SWIFT_VERSION = 4.0; 407 | TARGETED_DEVICE_FAMILY = "1,2"; 408 | }; 409 | name = Debug; 410 | }; 411 | 76774FEA204D7176008B6F3D /* Release */ = { 412 | isa = XCBuildConfiguration; 413 | buildSettings = { 414 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 415 | CODE_SIGN_STYLE = Automatic; 416 | DEVELOPMENT_TEAM = 2RNKT55WYW; 417 | INFOPLIST_FILE = AppleMusicTransition/Info.plist; 418 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 419 | PRODUCT_BUNDLE_IDENTIFIER = zby.AppleMusicTransition; 420 | PRODUCT_NAME = "$(TARGET_NAME)"; 421 | SWIFT_VERSION = 4.0; 422 | TARGETED_DEVICE_FAMILY = "1,2"; 423 | }; 424 | name = Release; 425 | }; 426 | 76774FEC204D7176008B6F3D /* Debug */ = { 427 | isa = XCBuildConfiguration; 428 | buildSettings = { 429 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 430 | BUNDLE_LOADER = "$(TEST_HOST)"; 431 | CODE_SIGN_STYLE = Automatic; 432 | DEVELOPMENT_TEAM = 2RNKT55WYW; 433 | INFOPLIST_FILE = AppleMusicTransitionTests/Info.plist; 434 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 435 | PRODUCT_BUNDLE_IDENTIFIER = zby.AppleMusicTransitionTests; 436 | PRODUCT_NAME = "$(TARGET_NAME)"; 437 | SWIFT_VERSION = 4.0; 438 | TARGETED_DEVICE_FAMILY = "1,2"; 439 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/AppleMusicTransition.app/AppleMusicTransition"; 440 | }; 441 | name = Debug; 442 | }; 443 | 76774FED204D7176008B6F3D /* Release */ = { 444 | isa = XCBuildConfiguration; 445 | buildSettings = { 446 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 447 | BUNDLE_LOADER = "$(TEST_HOST)"; 448 | CODE_SIGN_STYLE = Automatic; 449 | DEVELOPMENT_TEAM = 2RNKT55WYW; 450 | INFOPLIST_FILE = AppleMusicTransitionTests/Info.plist; 451 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 452 | PRODUCT_BUNDLE_IDENTIFIER = zby.AppleMusicTransitionTests; 453 | PRODUCT_NAME = "$(TARGET_NAME)"; 454 | SWIFT_VERSION = 4.0; 455 | TARGETED_DEVICE_FAMILY = "1,2"; 456 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/AppleMusicTransition.app/AppleMusicTransition"; 457 | }; 458 | name = Release; 459 | }; 460 | /* End XCBuildConfiguration section */ 461 | 462 | /* Begin XCConfigurationList section */ 463 | 76774FC6204D7176008B6F3D /* Build configuration list for PBXProject "AppleMusicTransition" */ = { 464 | isa = XCConfigurationList; 465 | buildConfigurations = ( 466 | 76774FE6204D7176008B6F3D /* Debug */, 467 | 76774FE7204D7176008B6F3D /* Release */, 468 | ); 469 | defaultConfigurationIsVisible = 0; 470 | defaultConfigurationName = Release; 471 | }; 472 | 76774FE8204D7176008B6F3D /* Build configuration list for PBXNativeTarget "AppleMusicTransition" */ = { 473 | isa = XCConfigurationList; 474 | buildConfigurations = ( 475 | 76774FE9204D7176008B6F3D /* Debug */, 476 | 76774FEA204D7176008B6F3D /* Release */, 477 | ); 478 | defaultConfigurationIsVisible = 0; 479 | defaultConfigurationName = Release; 480 | }; 481 | 76774FEB204D7176008B6F3D /* Build configuration list for PBXNativeTarget "AppleMusicTransitionTests" */ = { 482 | isa = XCConfigurationList; 483 | buildConfigurations = ( 484 | 76774FEC204D7176008B6F3D /* Debug */, 485 | 76774FED204D7176008B6F3D /* Release */, 486 | ); 487 | defaultConfigurationIsVisible = 0; 488 | defaultConfigurationName = Release; 489 | }; 490 | /* End XCConfigurationList section */ 491 | }; 492 | rootObject = 76774FC3204D7176008B6F3D /* Project object */; 493 | } 494 | -------------------------------------------------------------------------------- /AppleMusicTransition.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /AppleMusicTransition/Animator/AMPresentInteractiveAnimator.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AMPresentInteractiveAnimator.swift 3 | // AppleMusicTransition 4 | // 5 | // Created by 朱 冰一 on 2018/03/07. 6 | // Copyright © 2018年 cookie. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import UIKit 11 | 12 | protocol AMPresentInteractiveDelegate : class { 13 | func presentInteractive() 14 | } 15 | 16 | class AMPresentInteractiveAnimator: UIPercentDrivenInteractiveTransition { 17 | 18 | private var view: UIView 19 | weak var delegate: AMPresentInteractiveDelegate? 20 | private var shouldComplete = false 21 | init(attachTo view: UIView) { 22 | self.view = view 23 | super.init() 24 | setPanGesture(view: view) 25 | } 26 | 27 | private func setPanGesture(view: UIView) { 28 | let gesture = UIPanGestureRecognizer(target: self, action: #selector(handlePanGesture(gesture:))) 29 | view.addGestureRecognizer(gesture) 30 | } 31 | 32 | @objc private func handlePanGesture(gesture: UIPanGestureRecognizer) { 33 | let viewTransition = gesture.translation(in: view) 34 | let progress = -viewTransition.y / (UIScreen.main.bounds.height - Const.MusicPlayBarHeight - Const.StatusBarHeight) 35 | switch gesture.state { 36 | case .began: 37 | delegate?.presentInteractive() 38 | case .changed: 39 | shouldComplete = progress > 0.3 40 | update(progress) 41 | case .cancelled: 42 | cancel() 43 | case .ended: 44 | shouldComplete ? finish() : cancel() 45 | break 46 | default: 47 | break 48 | } 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /AppleMusicTransition/Animator/AMPresentationController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AMPresentationController.swift 3 | // AppleMusicTransition 4 | // 5 | // Created by cookie on 06/03/2018. 6 | // Copyright © 2018 cookie. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | //for present 11 | class AMPresentationController: UIPresentationController { 12 | 13 | var duration: TimeInterval = 0.6 14 | var isPresenting = false 15 | var fakeTabbar: UIView? 16 | 17 | private var blackLayer: UIView = { 18 | let view = UIView() 19 | view.backgroundColor = .black 20 | view.alpha = 0.0 21 | return view 22 | }() 23 | 24 | override func presentationTransitionWillBegin() { 25 | guard let fromView = presentingViewController.view else { return } 26 | guard let coordinator = presentedViewController.transitionCoordinator else { return } 27 | guard let presentingVC = presentingViewController as? TabBarViewController else { return } 28 | guard let contentesView = presentingVC.selectedViewController?.view else { return } 29 | 30 | blackLayer.frame = fromView.frame 31 | contentesView.addSubview(blackLayer) 32 | coordinator.animate(alongsideTransition: { (context) in 33 | self.blackLayer.alpha = 0.5 34 | }) { (_) in 35 | 36 | } 37 | } 38 | } 39 | 40 | // for dismiss 41 | extension AMPresentationController { 42 | override func dismissalTransitionWillBegin() { 43 | guard let coordinator = presentedViewController.transitionCoordinator else { return } 44 | coordinator.animate(alongsideTransition: { (context) in 45 | self.blackLayer.alpha = 0.0 46 | }) { (context) in 47 | if !context.isCancelled { 48 | self.blackLayer.removeFromSuperview() 49 | } 50 | } 51 | } 52 | } 53 | 54 | extension AMPresentationController: UIViewControllerAnimatedTransitioning { 55 | func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval { 56 | return duration 57 | } 58 | 59 | func animateTransition(using transitionContext: UIViewControllerContextTransitioning) { 60 | guard let presented = presentedView else { return } 61 | guard let container = containerView else { return } 62 | 63 | guard let presentedVC = presentedViewController as? MusicDetailViewController else { return } 64 | guard let presentingVC = presentingViewController as? TabBarViewController else { return } 65 | guard let contentesView = presentingVC.selectedViewController?.view else { return } 66 | if isPresenting { 67 | fakeTabbar = presentingVC.tabBar.snapshotView(afterScreenUpdates: false) 68 | fakeTabbar?.frame = presentingVC.tabBar.frame 69 | container.addSubview(presented) 70 | container.addSubview(fakeTabbar!) 71 | presented.frame = CGRect(x: 0, y: container.bounds.height - Const.MusicPlayBarHeight, width: container.bounds.width, height: Const.MusicPlayBarHeight) 72 | UIView.animate(withDuration: duration, delay: 0, usingSpringWithDamping: 0.9, initialSpringVelocity: 0.5, options: .curveEaseInOut, animations: { 73 | contentesView.layer.cornerRadius = 10 74 | contentesView.clipsToBounds = true 75 | contentesView.transform = contentesView.transform.scaledBy(x: 0.95, y: 0.95) 76 | contentesView.transform = contentesView.transform.translatedBy(x: 0, y: 20 - container.bounds.height * 0.05 / 2) 77 | presentingVC.tabBar.frame = presentingVC.tabBar.frame.offsetBy(dx: 0, dy: presentingVC.tabBar.bounds.height) 78 | self.fakeTabbar!.frame = self.fakeTabbar!.frame.offsetBy(dx: 0, dy: self.fakeTabbar!.bounds.height) 79 | 80 | presentedVC.frameAfterPresent() 81 | presented.frame = CGRect(x: 0, y: Const.MusicDetailTopPadding, width: container.bounds.width, height: container.bounds.height - Const.MusicDetailTopPadding) 82 | presented.layer.cornerRadius = 10 83 | presented.clipsToBounds = true 84 | }, completion: { (_) in 85 | transitionContext.completeTransition(!transitionContext.transitionWasCancelled) 86 | }) 87 | } else { 88 | UIView.animate(withDuration: duration, delay: 0, usingSpringWithDamping: 0.8, initialSpringVelocity: 0.5, options: .curveEaseInOut, animations: { 89 | contentesView.layer.cornerRadius = 0 90 | contentesView.transform = CGAffineTransform.identity 91 | contentesView.frame = container.frame 92 | presentingVC.tabBar.frame = presentingVC.tabBar.frame.offsetBy(dx: 0, dy: -presentingVC.tabBar.bounds.height) 93 | presentingVC.playBar.isHidden = true 94 | self.fakeTabbar!.frame = self.fakeTabbar!.frame.offsetBy(dx: 0, dy: -self.fakeTabbar!.bounds.height) 95 | 96 | presentedVC.frameBeforePresent() 97 | presented.layer.cornerRadius = 0 98 | presented.frame = CGRect(x: 0, y: container.bounds.height - Const.MusicPlayBarHeight, width: container.bounds.width, height: Const.MusicPlayBarHeight) 99 | }, completion: { (_) in 100 | if !transitionContext.transitionWasCancelled { 101 | self.fakeTabbar?.removeFromSuperview() 102 | self.fakeTabbar = nil 103 | presentingVC.playBar.isHidden = false 104 | } 105 | transitionContext.completeTransition(!transitionContext.transitionWasCancelled) 106 | }) 107 | } 108 | 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /AppleMusicTransition/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // AppleMusicTransition 4 | // 5 | // Created by cookie on 05/03/2018. 6 | // Copyright © 2018 cookie. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(_ application: UIApplication) { 23 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 24 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 25 | } 26 | 27 | func applicationDidEnterBackground(_ application: UIApplication) { 28 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | } 31 | 32 | func applicationWillEnterForeground(_ application: UIApplication) { 33 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 34 | } 35 | 36 | func applicationDidBecomeActive(_ application: UIApplication) { 37 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 38 | } 39 | 40 | func applicationWillTerminate(_ application: UIApplication) { 41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42 | } 43 | 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /AppleMusicTransition/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /AppleMusicTransition/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /AppleMusicTransition/Assets.xcassets/cover.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "cover.jpg", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /AppleMusicTransition/Assets.xcassets/cover.imageset/cover.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cookiezby/AppleMusicTransition/86e482ed930e460211aa0d40e35021e216469ad6/AppleMusicTransition/Assets.xcassets/cover.imageset/cover.jpg -------------------------------------------------------------------------------- /AppleMusicTransition/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 | -------------------------------------------------------------------------------- /AppleMusicTransition/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 | -------------------------------------------------------------------------------- /AppleMusicTransition/Const.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Const.swift 3 | // AppleMusicTransition 4 | // 5 | // Created by 朱 冰一 on 2018/03/07. 6 | // Copyright © 2018年 cookie. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import UIKit 11 | 12 | struct Const { 13 | static let MusicDetailTopPadding: CGFloat = 35 14 | static let MusicPlayBarHeight: CGFloat = 120 15 | static let StatusBarHeight = UIApplication.shared.statusBarFrame.height 16 | static let HomeMinScale: CGFloat = 0.95 17 | } 18 | -------------------------------------------------------------------------------- /AppleMusicTransition/Controller/MusicDetailViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MusicDetailViewController.swift 3 | // AppleMusicTransition 4 | // 5 | // Created by cookie on 05/03/2018. 6 | // Copyright © 2018 cookie. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | protocol MusicDetailViewControllerDelegate: class{ 12 | func update(_ progress: CGFloat) 13 | } 14 | 15 | class MusicDetailViewController: UIViewController { 16 | private let coverImage: UIImageView = { 17 | let view = UIImageView(image: UIImage(named: "cover")) 18 | view.clipsToBounds = true 19 | view.isUserInteractionEnabled = true 20 | return view 21 | }() 22 | 23 | private let headerButton: UIButton = { 24 | let button = UIButton() 25 | button.layer.cornerRadius = 2 26 | button.backgroundColor = UIColor.lightGray 27 | return button 28 | }() 29 | 30 | private var originFrame = CGRect(x: 0, y: 0, width: 0, height: 1) 31 | weak var delegate: MusicDetailViewControllerDelegate? 32 | 33 | override func viewDidLoad() { 34 | super.viewDidLoad() 35 | view.backgroundColor = .white 36 | view.addSubview(coverImage) 37 | view.addSubview(headerButton) 38 | headerButton.addTarget(self, action: #selector(handleTap(_:)), for: .touchUpInside) 39 | let pan = UIPanGestureRecognizer(target: self, action: #selector(handlePan(gesture:))) 40 | view.addGestureRecognizer(pan) 41 | 42 | frameBeforePresent() 43 | } 44 | 45 | func frameBeforePresent() { 46 | headerButton.isHidden = true 47 | coverImage.layer.cornerRadius = 3 48 | coverImage.frame = CGRect(x: 20, y: 10, width: 50, height: 50) 49 | } 50 | 51 | func frameAfterPresent() { 52 | headerButton.isHidden = false 53 | headerButton.frame = CGRect(x: (view.bounds.width - 100) / 2, y: 10, width: 100, height: 5) 54 | let coverWidth = view.bounds.width * 0.8 55 | coverImage.layer.cornerRadius = 8 56 | coverImage.frame = CGRect(x: (view.bounds.width - coverWidth) / 2, y: 40, width: coverWidth, height: coverWidth) 57 | } 58 | 59 | override func didReceiveMemoryWarning() { 60 | super.didReceiveMemoryWarning() 61 | } 62 | 63 | @objc private func handleTap(_ sender: UITapGestureRecognizer) { 64 | dismiss(animated: true, completion: nil) 65 | } 66 | 67 | @objc private func handlePan(gesture: UIPanGestureRecognizer) { 68 | let viewTransition = gesture.translation(in: view) 69 | let progress = viewTransition.y / (originFrame.height - Const.MusicPlayBarHeight) 70 | switch gesture.state { 71 | case .began: 72 | originFrame = view.frame 73 | case .changed: 74 | update(progress) 75 | case .cancelled: 76 | break 77 | case .ended: 78 | if progress > 0.2 { 79 | dismiss(animated: true, completion: nil) 80 | } else { 81 | UIView.animate(withDuration: 0.2 + 0.2 * Double(progress), delay: 0, options: .curveEaseInOut, animations: { 82 | self.delegate?.update(0) 83 | self.view.frame = self.originFrame 84 | }) 85 | } 86 | break 87 | default: 88 | break 89 | } 90 | } 91 | 92 | private func update(_ progress: CGFloat) { 93 | delegate?.update(progress) 94 | view.frame = CGRect(x: 0, y: originFrame.origin.y + (originFrame.height - Const.MusicPlayBarHeight) * progress, width: view.bounds.width, height: view.bounds.height) 95 | } 96 | 97 | override var preferredStatusBarStyle: UIStatusBarStyle { 98 | return .lightContent 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /AppleMusicTransition/Controller/TabBarViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TabBarViewController.swift 3 | // AppleMusicTransition 4 | // 5 | // Created by cookie on 05/03/2018. 6 | // Copyright © 2018 cookie. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | class TabBarViewController: UITabBarController { 11 | var playBar: PlayBarView! 12 | var presentationAnimator: AMPresentationController? 13 | var presentInteractiveAnimator: AMPresentInteractiveAnimator? 14 | 15 | override func viewDidLoad() { 16 | super.viewDidLoad() 17 | tabBar.barTintColor = .white 18 | playBar = PlayBarView(frame: CGRect(x: 0, y: view.bounds.height - 120, width: view.bounds.width, height: 120)) 19 | view.insertSubview(playBar, belowSubview: tabBar) 20 | 21 | let tap = UITapGestureRecognizer(target: self, action: #selector(handleTap(_:))) 22 | playBar.addGestureRecognizer(tap) 23 | 24 | presentInteractiveAnimator = AMPresentInteractiveAnimator(attachTo: playBar) 25 | presentInteractiveAnimator?.delegate = self 26 | } 27 | 28 | @objc func handleTap(_ sender: UITapGestureRecognizer) { 29 | presentDetail() 30 | } 31 | 32 | override func didReceiveMemoryWarning() { 33 | super.didReceiveMemoryWarning() 34 | } 35 | 36 | private func presentDetail() { 37 | let vc = MusicDetailViewController() 38 | vc.transitioningDelegate = self 39 | vc.modalPresentationStyle = .custom 40 | vc.modalPresentationCapturesStatusBarAppearance = true 41 | vc.delegate = self 42 | present(vc, animated: true, completion: nil) 43 | } 44 | } 45 | 46 | extension TabBarViewController: UIViewControllerTransitioningDelegate { 47 | func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning? { 48 | presentationAnimator?.isPresenting = true 49 | return presentationAnimator 50 | } 51 | 52 | func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? { 53 | presentationAnimator?.isPresenting = false 54 | return presentationAnimator 55 | } 56 | 57 | func presentationController(forPresented presented: UIViewController, presenting: UIViewController?, source: UIViewController) -> UIPresentationController? { 58 | self.presentationAnimator = AMPresentationController(presentedViewController: presented, presenting: presenting) 59 | return presentationAnimator 60 | } 61 | 62 | func interactionControllerForPresentation(using animator: UIViewControllerAnimatedTransitioning) -> UIViewControllerInteractiveTransitioning? { 63 | return presentInteractiveAnimator 64 | } 65 | } 66 | 67 | extension TabBarViewController: MusicDetailViewControllerDelegate { 68 | func update(_ progress: CGFloat) { 69 | guard let currView = selectedViewController?.view else { return } 70 | currView.transform = CGAffineTransform.identity.scaledBy(x: 0.95 + 0.05 * progress, y: 0.95 + 0.05 * progress) 71 | } 72 | } 73 | 74 | extension TabBarViewController: AMPresentInteractiveDelegate { 75 | func presentInteractive() { 76 | presentDetail() 77 | } 78 | } 79 | 80 | 81 | -------------------------------------------------------------------------------- /AppleMusicTransition/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 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /AppleMusicTransition/View/PlayBarView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PlayBarView.swift 3 | // AppleMusicTransition 4 | // 5 | // Created by cookie on 05/03/2018. 6 | // Copyright © 2018 cookie. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import UIKit 11 | 12 | class PlayBarView: UIView { 13 | private let thumbnailView: UIImageView = { 14 | let view = UIImageView(image: UIImage(named: "cover")) 15 | view.contentMode = .scaleAspectFit 16 | view.layer.shadowOpacity = 0.3 17 | view.layer.shadowColor = UIColor.black.cgColor 18 | view.layer.shadowOffset = CGSize(width: 3, height: 3) 19 | view.layer.shadowRadius = 10 20 | view.layer.cornerRadius = 3 21 | view.clipsToBounds = true 22 | return view 23 | }() 24 | 25 | override init(frame: CGRect) { 26 | super.init(frame: frame) 27 | backgroundColor = .white 28 | addSubview(thumbnailView) 29 | thumbnailView.frame = CGRect(x: 20, y: 10, width: 50, height: 50) 30 | } 31 | 32 | required init?(coder aDecoder: NSCoder) { 33 | fatalError("init(coder:) has not been implemented") 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /AppleMusicTransitionTests/AppleMusicTransitionTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppleMusicTransitionTests.swift 3 | // AppleMusicTransitionTests 4 | // 5 | // Created by cookie on 05/03/2018. 6 | // Copyright © 2018 cookie. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | @testable import AppleMusicTransition 11 | 12 | class AppleMusicTransitionTests: XCTestCase { 13 | 14 | override func setUp() { 15 | super.setUp() 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | } 18 | 19 | override func tearDown() { 20 | // Put teardown code here. This method is called after the invocation of each test method in the class. 21 | super.tearDown() 22 | } 23 | 24 | func testExample() { 25 | // This is an example of a functional test case. 26 | // Use XCTAssert and related functions to verify your tests produce the correct results. 27 | } 28 | 29 | func testPerformanceExample() { 30 | // This is an example of a performance test case. 31 | self.measure { 32 | // Put the code you want to measure the time of here. 33 | } 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /AppleMusicTransitionTests/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 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AppleMusicTransition 2 | 3 | 4 | -------------------------------------------------------------------------------- /sample.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cookiezby/AppleMusicTransition/86e482ed930e460211aa0d40e35021e216469ad6/sample.gif --------------------------------------------------------------------------------