├── .DS_Store ├── .gitignore ├── README.md ├── XX3DRiseAndFall.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata └── XX3DRiseAndFall ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets └── AppIcon.appiconset │ └── Contents.json ├── Base.lproj ├── LaunchScreen.storyboard ├── Main.storyboard └── second.storyboard ├── Info.plist ├── SecondController.h ├── SecondController.m ├── UIViewController+Category ├── UIViewController+XX3DFallAndRise.h ├── UIViewController+XX3DFallAndRise.m ├── UIViewController+XXProgressTool.h ├── UIViewController+XXProgressTool.m ├── UIViewController+XXPushAnimation.h └── UIViewController+XXPushAnimation.m ├── ViewController.h ├── ViewController.m └── main.m /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coderlinxx/XX3DRiseAndFall/934ed02e55db1f508608e1e00f51978ad38fb230/.DS_Store -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata/ 19 | 20 | ## Other 21 | *.moved-aside 22 | *.xcuserstate 23 | 24 | ## Obj-C/Swift specific 25 | *.hmap 26 | *.ipa 27 | *.dSYM.zip 28 | *.dSYM 29 | 30 | # CocoaPods 31 | # 32 | # We recommend against adding the Pods directory to your .gitignore. However 33 | # you should judge for yourself, the pros and cons are mentioned at: 34 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 35 | # 36 | # Pods/ 37 | 38 | # Carthage 39 | # 40 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 41 | # Carthage/Checkouts 42 | 43 | Carthage/Build 44 | 45 | # fastlane 46 | # 47 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 48 | # screenshots whenever they are needed. 49 | # For more information about the recommended setup visit: 50 | # https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md 51 | 52 | fastlane/report.xml 53 | fastlane/screenshots 54 | 55 | #Code Injection 56 | # 57 | # After new code Injection tools there's a generated folder /iOSInjectionProject 58 | # https://github.com/johnno1962/injectionforxcode 59 | 60 | iOSInjectionProject/ 61 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # XX3DRiseAndFall 2 | 通过 ViewController+Category 的方式实现类似电商等项目中控制器在3D方向上的z轴下沉位移效果. 3 | 4 | 在项目过程中所涉及到的一个需求,效果和天猫京东等的那种控制器下沉,然后具体商品型号类型等的展示view弹出的效果差不多,经过一些研究查阅之后做了一个非常简单的实现,大体效果如下: 5 | ![record2.gif](http://upload-images.jianshu.io/upload_images/1717878-706406afe9762662.gif?imageMogr2/auto-orient/strip) 6 | 7 | 实现方式是通过 ViewController+Category 的方式实现的,用分类的方式来实现不会对原有类产生任何影响. 8 | 9 | 动画过程全都是以CATransform3D类来实现的,大体想法是以z轴为主要划分轴,在x轴上来绕z轴转动,将下沉和上升的动画都区分成了两段动画,以下沉为例来分析: 10 | 11 | 第一段动画为视图绕x轴在z轴上的下沉过程: 12 | 13 | ![record4.gif](http://upload-images.jianshu.io/upload_images/1717878-88feddf921f6a746.gif?imageMogr2/auto-orient/strip) 14 | 15 | 16 | 动画过程核心代码: 17 | ``` 18 | - (CATransform3D)firstTransformType:(TransformType)type{ 19 |      20 |     CATransform3D t1 = CATransform3DIdentity; 21 |     CGFloat m = 1.0/-900; 22 |     switch (type) { 23 |         case TransformTypeM32: 24 |             t1.m32 = m; 25 |             break; 26 |         default: 27 |             t1.m34 = m; 28 |             break; 29 |     } 30 |      31 |     //缩放 32 |     t1 = CATransform3DScale(t1, 0.95, 0.95, 1); 33 |     //绕x轴旋转 34 |     t1 = CATransform3DRotate(t1, 15.0 * M_PI/180.0, 1, 0, 0); 35 |     return t1; 36 |      37 | } 38 | ``` 39 | 40 | 第二段动画为视图绕x轴在z轴上的上升过程,与第一段连起来做就是如下效果: 41 | 42 | 43 | ![record6.gif](http://upload-images.jianshu.io/upload_images/1717878-d50c6fdfa8e570d6.gif?imageMogr2/auto-orient/strip) 44 | 45 | 46 | 动画过程核心代码: 47 | ``` 48 | - (CATransform3D)secondTransformType:(TransformType)type{ 49 |      50 |     CATransform3D t2 = CATransform3DIdentity; 51 |     switch (type) { 52 |         case TransformTypeM32: 53 |             t2.m32 = [self firstTransformType:type].m32; 54 |             break; 55 |         default: 56 |             t2.m34 = [self firstTransformType:type].m34; 57 |             break; 58 |     } 59 |      60 |     //向上移 61 |     t2 = CATransform3DTranslate(t2, 0, self.view.frame.size.height * (-0.08), 0); 62 |     //第二次缩放 63 |     t2 = CATransform3DScale(t2, 0.8, 0.8, 1); 64 |     return t2; 65 | } 66 | ``` 67 | 这样的话一个下沉的效果就完成了,还原的做法正好是把这两段动画反过来,所以就不需要多说了.. 68 | PS: 如果不处理导航条的话,在实际应用过程中会出现非常low的当前控制器下沉了,但是导航条没有变化的效果,所以在这里也已经把当前控制器有没有在navigationBar上做了处理 69 | 最后效果: 70 | 71 | ![record8.gif](http://upload-images.jianshu.io/upload_images/1717878-5ead63e249f4de06.gif?imageMogr2/auto-orient/strip) 72 | 73 | 调用非常的简单,只要在控制器里如下调用就好了: 74 | ``` 75 | - (IBAction)fallWithNav:(UIButton *)sender { 76 | [self showWithDuration:0.5 transformType:TransformTypeM32]; 77 | } 78 | 79 | - (IBAction)riseWithNav:(UIButton *)sender { 80 | [self closeWithDuration:0.5 transformType:TransformTypeM32]; 81 | } 82 | ``` 83 | -------------------------------------------------------------------------------- /XX3DRiseAndFall.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 7E5DA3271E2770960046E64D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 7E5DA3261E2770960046E64D /* main.m */; }; 11 | 7E5DA32A1E2770960046E64D /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7E5DA3291E2770960046E64D /* AppDelegate.m */; }; 12 | 7E5DA32D1E2770960046E64D /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7E5DA32C1E2770960046E64D /* ViewController.m */; }; 13 | 7E5DA3301E2770960046E64D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 7E5DA32E1E2770960046E64D /* Main.storyboard */; }; 14 | 7E5DA3321E2770960046E64D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 7E5DA3311E2770960046E64D /* Assets.xcassets */; }; 15 | 7E5DA3351E2770960046E64D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 7E5DA3331E2770960046E64D /* LaunchScreen.storyboard */; }; 16 | 7E5DA3451E2771140046E64D /* UIViewController+XXPushAnimation.m in Sources */ = {isa = PBXBuildFile; fileRef = 7E5DA3421E2771140046E64D /* UIViewController+XXPushAnimation.m */; }; 17 | 7E5DA3481E277B380046E64D /* UIViewController+XX3DFallAndRise.m in Sources */ = {isa = PBXBuildFile; fileRef = 7E5DA3471E277B380046E64D /* UIViewController+XX3DFallAndRise.m */; }; 18 | 7E5DA34B1E2884C70046E64D /* second.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 7E5DA3491E2884C70046E64D /* second.storyboard */; }; 19 | 7E5DA34E1E289DAA0046E64D /* SecondController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7E5DA34D1E289DAA0046E64D /* SecondController.m */; }; 20 | /* End PBXBuildFile section */ 21 | 22 | /* Begin PBXFileReference section */ 23 | 7E5DA3221E2770960046E64D /* XX3DRiseAndFall.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = XX3DRiseAndFall.app; sourceTree = BUILT_PRODUCTS_DIR; }; 24 | 7E5DA3261E2770960046E64D /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 25 | 7E5DA3281E2770960046E64D /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 26 | 7E5DA3291E2770960046E64D /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 27 | 7E5DA32B1E2770960046E64D /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 28 | 7E5DA32C1E2770960046E64D /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 29 | 7E5DA32F1E2770960046E64D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 30 | 7E5DA3311E2770960046E64D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 31 | 7E5DA3341E2770960046E64D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 32 | 7E5DA3361E2770960046E64D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 33 | 7E5DA3411E2771140046E64D /* UIViewController+XXPushAnimation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIViewController+XXPushAnimation.h"; sourceTree = ""; }; 34 | 7E5DA3421E2771140046E64D /* UIViewController+XXPushAnimation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIViewController+XXPushAnimation.m"; sourceTree = ""; }; 35 | 7E5DA3461E277B380046E64D /* UIViewController+XX3DFallAndRise.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIViewController+XX3DFallAndRise.h"; sourceTree = ""; }; 36 | 7E5DA3471E277B380046E64D /* UIViewController+XX3DFallAndRise.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIViewController+XX3DFallAndRise.m"; sourceTree = ""; }; 37 | 7E5DA34A1E2884C70046E64D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/second.storyboard; sourceTree = ""; }; 38 | 7E5DA34C1E289DAA0046E64D /* SecondController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SecondController.h; sourceTree = ""; }; 39 | 7E5DA34D1E289DAA0046E64D /* SecondController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SecondController.m; sourceTree = ""; }; 40 | /* End PBXFileReference section */ 41 | 42 | /* Begin PBXFrameworksBuildPhase section */ 43 | 7E5DA31F1E2770960046E64D /* Frameworks */ = { 44 | isa = PBXFrameworksBuildPhase; 45 | buildActionMask = 2147483647; 46 | files = ( 47 | ); 48 | runOnlyForDeploymentPostprocessing = 0; 49 | }; 50 | /* End PBXFrameworksBuildPhase section */ 51 | 52 | /* Begin PBXGroup section */ 53 | 7E5DA3191E2770960046E64D = { 54 | isa = PBXGroup; 55 | children = ( 56 | 7E5DA3241E2770960046E64D /* XX3DRiseAndFall */, 57 | 7E5DA3231E2770960046E64D /* Products */, 58 | ); 59 | sourceTree = ""; 60 | }; 61 | 7E5DA3231E2770960046E64D /* Products */ = { 62 | isa = PBXGroup; 63 | children = ( 64 | 7E5DA3221E2770960046E64D /* XX3DRiseAndFall.app */, 65 | ); 66 | name = Products; 67 | sourceTree = ""; 68 | }; 69 | 7E5DA3241E2770960046E64D /* XX3DRiseAndFall */ = { 70 | isa = PBXGroup; 71 | children = ( 72 | 7E5DA33C1E2771140046E64D /* UIViewController+Category */, 73 | 7E5DA3281E2770960046E64D /* AppDelegate.h */, 74 | 7E5DA3291E2770960046E64D /* AppDelegate.m */, 75 | 7E5DA32B1E2770960046E64D /* ViewController.h */, 76 | 7E5DA32C1E2770960046E64D /* ViewController.m */, 77 | 7E5DA34C1E289DAA0046E64D /* SecondController.h */, 78 | 7E5DA34D1E289DAA0046E64D /* SecondController.m */, 79 | 7E5DA32E1E2770960046E64D /* Main.storyboard */, 80 | 7E5DA3491E2884C70046E64D /* second.storyboard */, 81 | 7E5DA3311E2770960046E64D /* Assets.xcassets */, 82 | 7E5DA3331E2770960046E64D /* LaunchScreen.storyboard */, 83 | 7E5DA3361E2770960046E64D /* Info.plist */, 84 | 7E5DA3251E2770960046E64D /* Supporting Files */, 85 | ); 86 | path = XX3DRiseAndFall; 87 | sourceTree = ""; 88 | }; 89 | 7E5DA3251E2770960046E64D /* Supporting Files */ = { 90 | isa = PBXGroup; 91 | children = ( 92 | 7E5DA3261E2770960046E64D /* main.m */, 93 | ); 94 | name = "Supporting Files"; 95 | sourceTree = ""; 96 | }; 97 | 7E5DA33C1E2771140046E64D /* UIViewController+Category */ = { 98 | isa = PBXGroup; 99 | children = ( 100 | 7E5DA3411E2771140046E64D /* UIViewController+XXPushAnimation.h */, 101 | 7E5DA3421E2771140046E64D /* UIViewController+XXPushAnimation.m */, 102 | 7E5DA3461E277B380046E64D /* UIViewController+XX3DFallAndRise.h */, 103 | 7E5DA3471E277B380046E64D /* UIViewController+XX3DFallAndRise.m */, 104 | ); 105 | path = "UIViewController+Category"; 106 | sourceTree = ""; 107 | }; 108 | /* End PBXGroup section */ 109 | 110 | /* Begin PBXNativeTarget section */ 111 | 7E5DA3211E2770960046E64D /* XX3DRiseAndFall */ = { 112 | isa = PBXNativeTarget; 113 | buildConfigurationList = 7E5DA3391E2770960046E64D /* Build configuration list for PBXNativeTarget "XX3DRiseAndFall" */; 114 | buildPhases = ( 115 | 7E5DA31E1E2770960046E64D /* Sources */, 116 | 7E5DA31F1E2770960046E64D /* Frameworks */, 117 | 7E5DA3201E2770960046E64D /* Resources */, 118 | ); 119 | buildRules = ( 120 | ); 121 | dependencies = ( 122 | ); 123 | name = XX3DRiseAndFall; 124 | productName = XX3DRiseAndFall; 125 | productReference = 7E5DA3221E2770960046E64D /* XX3DRiseAndFall.app */; 126 | productType = "com.apple.product-type.application"; 127 | }; 128 | /* End PBXNativeTarget section */ 129 | 130 | /* Begin PBXProject section */ 131 | 7E5DA31A1E2770960046E64D /* Project object */ = { 132 | isa = PBXProject; 133 | attributes = { 134 | LastUpgradeCheck = 0730; 135 | ORGANIZATIONNAME = "GoGoGold E-Commerce Co.Ltd"; 136 | TargetAttributes = { 137 | 7E5DA3211E2770960046E64D = { 138 | CreatedOnToolsVersion = 7.3.1; 139 | }; 140 | }; 141 | }; 142 | buildConfigurationList = 7E5DA31D1E2770960046E64D /* Build configuration list for PBXProject "XX3DRiseAndFall" */; 143 | compatibilityVersion = "Xcode 3.2"; 144 | developmentRegion = English; 145 | hasScannedForEncodings = 0; 146 | knownRegions = ( 147 | en, 148 | Base, 149 | ); 150 | mainGroup = 7E5DA3191E2770960046E64D; 151 | productRefGroup = 7E5DA3231E2770960046E64D /* Products */; 152 | projectDirPath = ""; 153 | projectRoot = ""; 154 | targets = ( 155 | 7E5DA3211E2770960046E64D /* XX3DRiseAndFall */, 156 | ); 157 | }; 158 | /* End PBXProject section */ 159 | 160 | /* Begin PBXResourcesBuildPhase section */ 161 | 7E5DA3201E2770960046E64D /* Resources */ = { 162 | isa = PBXResourcesBuildPhase; 163 | buildActionMask = 2147483647; 164 | files = ( 165 | 7E5DA34B1E2884C70046E64D /* second.storyboard in Resources */, 166 | 7E5DA3351E2770960046E64D /* LaunchScreen.storyboard in Resources */, 167 | 7E5DA3321E2770960046E64D /* Assets.xcassets in Resources */, 168 | 7E5DA3301E2770960046E64D /* Main.storyboard in Resources */, 169 | ); 170 | runOnlyForDeploymentPostprocessing = 0; 171 | }; 172 | /* End PBXResourcesBuildPhase section */ 173 | 174 | /* Begin PBXSourcesBuildPhase section */ 175 | 7E5DA31E1E2770960046E64D /* Sources */ = { 176 | isa = PBXSourcesBuildPhase; 177 | buildActionMask = 2147483647; 178 | files = ( 179 | 7E5DA32D1E2770960046E64D /* ViewController.m in Sources */, 180 | 7E5DA3451E2771140046E64D /* UIViewController+XXPushAnimation.m in Sources */, 181 | 7E5DA32A1E2770960046E64D /* AppDelegate.m in Sources */, 182 | 7E5DA34E1E289DAA0046E64D /* SecondController.m in Sources */, 183 | 7E5DA3271E2770960046E64D /* main.m in Sources */, 184 | 7E5DA3481E277B380046E64D /* UIViewController+XX3DFallAndRise.m in Sources */, 185 | ); 186 | runOnlyForDeploymentPostprocessing = 0; 187 | }; 188 | /* End PBXSourcesBuildPhase section */ 189 | 190 | /* Begin PBXVariantGroup section */ 191 | 7E5DA32E1E2770960046E64D /* Main.storyboard */ = { 192 | isa = PBXVariantGroup; 193 | children = ( 194 | 7E5DA32F1E2770960046E64D /* Base */, 195 | ); 196 | name = Main.storyboard; 197 | sourceTree = ""; 198 | }; 199 | 7E5DA3331E2770960046E64D /* LaunchScreen.storyboard */ = { 200 | isa = PBXVariantGroup; 201 | children = ( 202 | 7E5DA3341E2770960046E64D /* Base */, 203 | ); 204 | name = LaunchScreen.storyboard; 205 | sourceTree = ""; 206 | }; 207 | 7E5DA3491E2884C70046E64D /* second.storyboard */ = { 208 | isa = PBXVariantGroup; 209 | children = ( 210 | 7E5DA34A1E2884C70046E64D /* Base */, 211 | ); 212 | name = second.storyboard; 213 | sourceTree = ""; 214 | }; 215 | /* End PBXVariantGroup section */ 216 | 217 | /* Begin XCBuildConfiguration section */ 218 | 7E5DA3371E2770960046E64D /* Debug */ = { 219 | isa = XCBuildConfiguration; 220 | buildSettings = { 221 | ALWAYS_SEARCH_USER_PATHS = NO; 222 | CLANG_ANALYZER_NONNULL = YES; 223 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 224 | CLANG_CXX_LIBRARY = "libc++"; 225 | CLANG_ENABLE_MODULES = YES; 226 | CLANG_ENABLE_OBJC_ARC = YES; 227 | CLANG_WARN_BOOL_CONVERSION = YES; 228 | CLANG_WARN_CONSTANT_CONVERSION = YES; 229 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 230 | CLANG_WARN_EMPTY_BODY = YES; 231 | CLANG_WARN_ENUM_CONVERSION = YES; 232 | CLANG_WARN_INT_CONVERSION = YES; 233 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 234 | CLANG_WARN_UNREACHABLE_CODE = YES; 235 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 236 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 237 | COPY_PHASE_STRIP = NO; 238 | DEBUG_INFORMATION_FORMAT = dwarf; 239 | ENABLE_STRICT_OBJC_MSGSEND = YES; 240 | ENABLE_TESTABILITY = YES; 241 | GCC_C_LANGUAGE_STANDARD = gnu99; 242 | GCC_DYNAMIC_NO_PIC = NO; 243 | GCC_NO_COMMON_BLOCKS = YES; 244 | GCC_OPTIMIZATION_LEVEL = 0; 245 | GCC_PREPROCESSOR_DEFINITIONS = ( 246 | "DEBUG=1", 247 | "$(inherited)", 248 | ); 249 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 250 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 251 | GCC_WARN_UNDECLARED_SELECTOR = YES; 252 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 253 | GCC_WARN_UNUSED_FUNCTION = YES; 254 | GCC_WARN_UNUSED_VARIABLE = YES; 255 | IPHONEOS_DEPLOYMENT_TARGET = 9.3; 256 | MTL_ENABLE_DEBUG_INFO = YES; 257 | ONLY_ACTIVE_ARCH = YES; 258 | SDKROOT = iphoneos; 259 | }; 260 | name = Debug; 261 | }; 262 | 7E5DA3381E2770960046E64D /* Release */ = { 263 | isa = XCBuildConfiguration; 264 | buildSettings = { 265 | ALWAYS_SEARCH_USER_PATHS = NO; 266 | CLANG_ANALYZER_NONNULL = YES; 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 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 283 | ENABLE_NS_ASSERTIONS = NO; 284 | ENABLE_STRICT_OBJC_MSGSEND = YES; 285 | GCC_C_LANGUAGE_STANDARD = gnu99; 286 | GCC_NO_COMMON_BLOCKS = YES; 287 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 288 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 289 | GCC_WARN_UNDECLARED_SELECTOR = YES; 290 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 291 | GCC_WARN_UNUSED_FUNCTION = YES; 292 | GCC_WARN_UNUSED_VARIABLE = YES; 293 | IPHONEOS_DEPLOYMENT_TARGET = 9.3; 294 | MTL_ENABLE_DEBUG_INFO = NO; 295 | SDKROOT = iphoneos; 296 | VALIDATE_PRODUCT = YES; 297 | }; 298 | name = Release; 299 | }; 300 | 7E5DA33A1E2770960046E64D /* Debug */ = { 301 | isa = XCBuildConfiguration; 302 | buildSettings = { 303 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 304 | INFOPLIST_FILE = XX3DRiseAndFall/Info.plist; 305 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 306 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 307 | PRODUCT_BUNDLE_IDENTIFIER = com.gogogold.XX3DRiseAndFall; 308 | PRODUCT_NAME = "$(TARGET_NAME)"; 309 | }; 310 | name = Debug; 311 | }; 312 | 7E5DA33B1E2770960046E64D /* Release */ = { 313 | isa = XCBuildConfiguration; 314 | buildSettings = { 315 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 316 | INFOPLIST_FILE = XX3DRiseAndFall/Info.plist; 317 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 318 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 319 | PRODUCT_BUNDLE_IDENTIFIER = com.gogogold.XX3DRiseAndFall; 320 | PRODUCT_NAME = "$(TARGET_NAME)"; 321 | }; 322 | name = Release; 323 | }; 324 | /* End XCBuildConfiguration section */ 325 | 326 | /* Begin XCConfigurationList section */ 327 | 7E5DA31D1E2770960046E64D /* Build configuration list for PBXProject "XX3DRiseAndFall" */ = { 328 | isa = XCConfigurationList; 329 | buildConfigurations = ( 330 | 7E5DA3371E2770960046E64D /* Debug */, 331 | 7E5DA3381E2770960046E64D /* Release */, 332 | ); 333 | defaultConfigurationIsVisible = 0; 334 | defaultConfigurationName = Release; 335 | }; 336 | 7E5DA3391E2770960046E64D /* Build configuration list for PBXNativeTarget "XX3DRiseAndFall" */ = { 337 | isa = XCConfigurationList; 338 | buildConfigurations = ( 339 | 7E5DA33A1E2770960046E64D /* Debug */, 340 | 7E5DA33B1E2770960046E64D /* Release */, 341 | ); 342 | defaultConfigurationIsVisible = 0; 343 | }; 344 | /* End XCConfigurationList section */ 345 | }; 346 | rootObject = 7E5DA31A1E2770960046E64D /* Project object */; 347 | } 348 | -------------------------------------------------------------------------------- /XX3DRiseAndFall.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /XX3DRiseAndFall/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // XX3DRiseAndFall 4 | // 5 | // Created by inxx on 17/1/12. 6 | // Copyright © 2017年 GoGoGold E-Commerce Co.Ltd. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /XX3DRiseAndFall/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // XX3DRiseAndFall 4 | // 5 | // Created by inxx on 17/1/12. 6 | // Copyright © 2017年 GoGoGold E-Commerce Co.Ltd. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | - (void)applicationWillResignActive:(UIApplication *)application { 24 | // 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. 25 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 26 | } 27 | 28 | - (void)applicationDidEnterBackground:(UIApplication *)application { 29 | // 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. 30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 31 | } 32 | 33 | - (void)applicationWillEnterForeground:(UIApplication *)application { 34 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 35 | } 36 | 37 | - (void)applicationDidBecomeActive:(UIApplication *)application { 38 | // 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. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application { 42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /XX3DRiseAndFall/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /XX3DRiseAndFall/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 | 27 | 28 | -------------------------------------------------------------------------------- /XX3DRiseAndFall/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 | -------------------------------------------------------------------------------- /XX3DRiseAndFall/Base.lproj/second.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 | 44 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /XX3DRiseAndFall/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 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /XX3DRiseAndFall/SecondController.h: -------------------------------------------------------------------------------- 1 | // 2 | // SecondController.h 3 | // XX3DRiseAndFall 4 | // 5 | // Created by inxx on 17/1/13. 6 | // Copyright © 2017年 GoGoGold E-Commerce Co.Ltd. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface SecondController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /XX3DRiseAndFall/SecondController.m: -------------------------------------------------------------------------------- 1 | // 2 | // SecondController.m 3 | // XX3DRiseAndFall 4 | // 5 | // Created by inxx on 17/1/13. 6 | // Copyright © 2017年 GoGoGold E-Commerce Co.Ltd. All rights reserved. 7 | // 8 | 9 | #import "SecondController.h" 10 | #import "UIViewController+XX3DFallAndRise.h" 11 | 12 | @interface SecondController () 13 | @end 14 | 15 | @implementation SecondController 16 | 17 | - (IBAction)fallWithNav:(UIButton *)sender { 18 | [self showWithDuration:0.5 transformType:TransformTypeM32]; 19 | } 20 | 21 | - (IBAction)riseWithNav:(UIButton *)sender { 22 | [self closeWithDuration:0.5 transformType:TransformTypeM32]; 23 | } 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /XX3DRiseAndFall/UIViewController+Category/UIViewController+XX3DFallAndRise.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+XX3DFallAndRise.h 3 | // XX3DRiseAndFall 4 | // 5 | // Created by inxx on 17/1/12. 6 | // Copyright © 2017年 GoGoGold E-Commerce Co.Ltd. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | typedef NS_ENUM(NSInteger, TransformType) { 12 | TransformTypeM32 = 0, 13 | TransformTypeM34, 14 | }; 15 | 16 | 17 | @interface UIViewController (XX3DFallAndRise) 18 | 19 | /** 3D形变展示 */ 20 | - (void)show; 21 | /** 3D形变关闭 */ 22 | - (void)close; 23 | /** 24 | * 3D形变展示 25 | * 26 | * @param duration 时长 27 | */ 28 | - (void)showWithDuration:(NSTimeInterval)duration; 29 | /** 30 | * 3D形变关闭 31 | * 32 | * @param duration 时长 33 | */ 34 | - (void)closeWithDuration:(NSTimeInterval)duration; 35 | 36 | 37 | /** 38 | * 3D形变展示 39 | * 40 | * @param duration 时长 41 | * @param type 动画类型 42 | */ 43 | - (void)showWithDuration:(NSTimeInterval)duration transformType:(TransformType)type; 44 | /** 45 | * 3D形变关闭 46 | * 47 | * @param duration 时长 48 | * @param type 动画类型 49 | */ 50 | - (void)closeWithDuration:(NSTimeInterval)duration transformType:(TransformType)type; 51 | 52 | @end 53 | -------------------------------------------------------------------------------- /XX3DRiseAndFall/UIViewController+Category/UIViewController+XX3DFallAndRise.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+XX3DFallAndRise.m 3 | // XX3DRiseAndFall 4 | // 5 | // Created by inxx on 17/1/12. 6 | // Copyright © 2017年 GoGoGold E-Commerce Co.Ltd. All rights reserved. 7 | // 8 | 9 | #import "UIViewController+XX3DFallAndRise.h" 10 | 11 | @implementation UIViewController (XX3DFallAndRise) 12 | 13 | - (void)show{ 14 | [self fallVcWithDuration:0.5f transformType:TransformTypeM34]; 15 | } 16 | - (void)showWithDuration:(NSTimeInterval)duration{ 17 | [self fallVcWithDuration:duration transformType:TransformTypeM34]; 18 | } 19 | - (void)close{ 20 | [self riseVcWithDuration:0.5f transformType:TransformTypeM34]; 21 | } 22 | - (void)closeWithDuration:(NSTimeInterval)duration{ 23 | [self riseVcWithDuration:duration transformType:TransformTypeM34]; 24 | } 25 | - (void)showWithDuration:(NSTimeInterval)duration transformType:(TransformType)type{ 26 | [self fallVcWithDuration:duration transformType:type]; 27 | } 28 | - (void)closeWithDuration:(NSTimeInterval)duration transformType:(TransformType)type{ 29 | [self riseVcWithDuration:0.5f transformType:type]; 30 | } 31 | 32 | 33 | - (void) riseVcWithDuration:(NSTimeInterval)duration transformType:(TransformType)type{ 34 | 35 | UIViewController *controller = [self getActionController]; 36 | 37 | [UIView animateWithDuration:duration/2 delay:0 options:UIViewAnimationOptionCurveEaseInOut animations:^{ 38 | 39 | [controller.view.layer setTransform:[self firstTransformType: type]]; 40 | 41 | } completion:^(BOOL finished) { 42 | 43 | [UIView animateWithDuration:duration/2 delay:0 options:UIViewAnimationOptionCurveEaseInOut animations:^{ 44 | 45 | [controller.view.layer setTransform:CATransform3DIdentity]; 46 | 47 | } completion:^(BOOL finished) { 48 | 49 | }]; 50 | 51 | }]; 52 | 53 | } 54 | 55 | - (void) fallVcWithDuration:(NSTimeInterval)duration transformType:(TransformType)type{ 56 | 57 | UIViewController *controller = [self getActionController]; 58 | 59 | [UIView animateWithDuration:duration/2 delay:0 options:UIViewAnimationOptionCurveEaseInOut animations:^{ 60 | 61 | [controller.view.layer setTransform:[self firstTransformType:type]]; 62 | 63 | } completion:^(BOOL finished) { 64 | 65 | [UIView animateWithDuration:duration/2 delay:0 options:UIViewAnimationOptionCurveEaseInOut animations:^{ 66 | 67 | [controller.view.layer setTransform:[self secondTransformType:type]]; 68 | 69 | } completion:^(BOOL finished) { 70 | 71 | }]; 72 | 73 | }]; 74 | 75 | } 76 | 77 | 78 | - (CATransform3D)firstTransformType:(TransformType)type{ 79 | 80 | CATransform3D t1 = CATransform3DIdentity; 81 | CGFloat m = 1.0/-900; 82 | switch (type) { 83 | case TransformTypeM32: 84 | t1.m32 = m; 85 | break; 86 | default: 87 | t1.m34 = m; 88 | break; 89 | } 90 | //t1.m32 = 1.0/-900; 91 | 92 | //带点缩小的效果 93 | t1 = CATransform3DScale(t1, 0.95, 0.95, 1); 94 | //绕x轴旋转 95 | t1 = CATransform3DRotate(t1, 15.0 * M_PI/180.0, 1, 0, 0); 96 | return t1; 97 | 98 | } 99 | 100 | - (CATransform3D)secondTransformType:(TransformType)type{ 101 | 102 | CATransform3D t2 = CATransform3DIdentity; 103 | switch (type) { 104 | case TransformTypeM32: 105 | t2.m32 = [self firstTransformType:type].m32; 106 | break; 107 | default: 108 | t2.m34 = [self firstTransformType:type].m34; 109 | break; 110 | } 111 | //t2.m32 = [self firstTransformType:type].m32; 112 | 113 | //向上移 114 | t2 = CATransform3DTranslate(t2, 0, self.view.frame.size.height * (-0.08), 0); 115 | //第二次缩小 116 | t2 = CATransform3DScale(t2, 0.8, 0.8, 1); 117 | return t2; 118 | } 119 | 120 | -(UIViewController *)getActionController{ 121 | return self.navigationController ? self.navigationController : self; 122 | } 123 | 124 | @end 125 | -------------------------------------------------------------------------------- /XX3DRiseAndFall/UIViewController+Category/UIViewController+XXProgressTool.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+XXProgressTool.h 3 | // 工厂店赚钱宝 4 | // 5 | // Created by inxx on 16/6/24. 6 | // Copyright © 2016年 GG. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "MKLoadingView.h" 11 | 12 | 13 | 14 | @interface UIViewController (XXProgressTool) 15 | 16 | /** 自定义加载进程 View */ 17 | @property(nonatomic, strong)MKLoadingView *loadingView; 18 | 19 | - (void)emptyView; 20 | - (void)emptyViewWithString:(NSString *)text; 21 | - (void)showLoadingView; 22 | - (void)hideLoadingView; 23 | - (void)failAndReLoadingView; 24 | -(void)failAndReLoadingFirstData; 25 | - (void)reLoadingViewEnabled:(BOOL)isYes; 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /XX3DRiseAndFall/UIViewController+Category/UIViewController+XXProgressTool.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+XXProgressTool.m 3 | // 工厂店赚钱宝 4 | // 5 | // Created by inxx on 16/6/24. 6 | // Copyright © 2016年 GG. All rights reserved. 7 | // 8 | 9 | #import "UIViewController+XXProgressTool.h" 10 | #import 11 | 12 | @implementation UIViewController (XXProgressTool) 13 | 14 | @dynamic loadingView; 15 | 16 | - (void)showLoadingView{ 17 | if (!self.loadingView) { 18 | MKLoadingView *loadingView = [[MKLoadingView alloc] init]; 19 | loadingView.backgroundColor = [UIColor colorWithRed:234 / 255.0 green:234 / 255.0 blue:234 / 255.0 alpha:1]; 20 | loadingView.userInteractionEnabled = NO; 21 | 22 | self.loadingView = loadingView; 23 | } 24 | [self.loadingView showLoadingViewWithText:@"正在载入中..." animated:YES]; 25 | } 26 | 27 | - (void)hideLoadingView{ 28 | [self.loadingView hideLoadingView]; 29 | } 30 | 31 | 32 | -(void)failAndReLoadingView{ 33 | UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(loadData)]; 34 | [self.loadingView addGestureRecognizer:tap]; 35 | self.loadingView.userInteractionEnabled = YES; 36 | [self.loadingView showReloadViewWithText:@"加载失败,点击屏幕重试"]; 37 | } 38 | 39 | -(void)failAndReLoadingFirstData{ 40 | UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(loadFirstData)]; 41 | [self.loadingView addGestureRecognizer:tap]; 42 | self.loadingView.userInteractionEnabled = YES; 43 | [self.loadingView showReloadViewWithText:@"加载失败,点击屏幕重试"]; 44 | } 45 | 46 | - (void)reLoadingViewEnabled:(BOOL)isYes{ 47 | UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(loadData)]; 48 | [self.loadingView addGestureRecognizer:tap]; 49 | self.loadingView.userInteractionEnabled = YES; 50 | [self.loadingView showReloadViewWithText:@"加载失败,点击屏幕重试"]; 51 | } 52 | -(void)loadData{ 53 | NSLog(@"loadData实现于具体控制器!"); 54 | } 55 | -(void)loadFirstData{ 56 | NSLog(@"loadFirstData实现于具体控制器!"); 57 | } 58 | 59 | - (void)emptyView{ 60 | [self.loadingView showReloadViewWithText:@"暂无数据"]; 61 | } 62 | 63 | - (void)emptyViewWithString:(NSString *)text{ 64 | [self.loadingView showReloadViewWithText:text]; 65 | } 66 | 67 | 68 | #pragma mark - runtime 69 | 70 | static const char *LoadingViewKey = "LoadingViewKey"; 71 | 72 | -(void)setLoadingView:(MKLoadingView *)loadingView{ 73 | if (loadingView != self.loadingView) { 74 | // 删除旧的,添加新的 75 | [self.loadingView removeFromSuperview]; 76 | [self.view addSubview:loadingView]; 77 | objc_setAssociatedObject(self, &LoadingViewKey, loadingView, OBJC_ASSOCIATION_RETAIN); 78 | } 79 | } 80 | 81 | -(MKLoadingView *)loadingView{ 82 | return objc_getAssociatedObject(self, &LoadingViewKey); 83 | } 84 | 85 | 86 | @end 87 | -------------------------------------------------------------------------------- /XX3DRiseAndFall/UIViewController+Category/UIViewController+XXPushAnimation.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+XXPushAnimation.h 3 | // XXPushAnimation 4 | // 5 | // Created by inxx on 16/8/29. 6 | // Copyright © 2016年 GoGoGold E-Commerce Co.Ltd. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | /** 动画类型 */ 12 | typedef NS_ENUM(NSInteger, AnimationType) { 13 | /** 淡入淡出 */ 14 | AnimationTypeFade = 1, //淡入淡出 15 | /** 推挤 */ 16 | AnimationTypePush, //推挤 17 | /**揭开 */ 18 | AnimationTypeReveal, //揭开 19 | /** 覆盖 */ 20 | AnimationTypeMoveIn, //覆盖 21 | /**立方体 */ 22 | AnimationTypeCube, //立方体 23 | /** 吮吸 */ 24 | AnimationTypeSuckEffect, //吮吸 25 | /** 翻转 */ 26 | AnimationTypeOglFlip, //翻转 27 | /** 波纹 */ 28 | AnimationTypeRippleEffect, //波纹 29 | /** 翻页 */ 30 | AnimationTypePageCurl, //翻页 31 | /** 反翻页 */ 32 | AnimationTypePageUnCurl, //反翻页 33 | /** 开镜头 */ 34 | AnimationTypeCameraIrisHollowOpen, //开镜头 35 | /** 关镜头 */ 36 | AnimationTypeCameraIrisHollowClose, //关镜头 37 | /** 下翻页 */ 38 | AnimationTypeCurlDown, //下翻页 39 | /** 上翻页 */ 40 | AnimationTypeCurlUp, //上翻页 41 | /** 左翻转 */ 42 | AnimationTypeFlipFromLeft, //左翻转 43 | /** 右翻转 */ 44 | AnimationTypeFlipFromRight, //右翻转 45 | }; 46 | 47 | @interface UIViewController (XXPushAnimation) 48 | 49 | 50 | /** 51 | * 控制器间跳转时的动画效果 52 | * 53 | * @param type 动画类型枚举值 54 | * @param subtype 动画子类型(动画的更详细效果) 55 | */ 56 | - (void) transitionWithEnumType:(AnimationType) animationType WithSubtype:(NSString *) subtype; 57 | 58 | 59 | /** 60 | * 视图间跳转时的动画效果 61 | * 62 | * @param type 动画类型 63 | * @param subtype 动画子类型(动画的更详细效果) 64 | * @param view 视图 65 | */ 66 | - (void) transitionWithType:(NSString *) type WithSubtype:(NSString *) subtype ForView : (UIView *) view; 67 | 68 | @end 69 | -------------------------------------------------------------------------------- /XX3DRiseAndFall/UIViewController+Category/UIViewController+XXPushAnimation.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+XXPushAnimation.h 3 | // XXPushAnimation 4 | // 5 | // Created by inxx on 16/8/29. 6 | // Copyright © 2016年 GoGoGold E-Commerce Co.Ltd. All rights reserved. 7 | // 8 | 9 | #import "UIViewController+XXPushAnimation.h" 10 | 11 | @implementation UIViewController (XXPushAnimation) 12 | 13 | - (void) transitionWithEnumType:(AnimationType) animationType WithSubtype:(NSString *) subtype{ 14 | 15 | //创建CATransition对象 16 | CATransition *animation = [CATransition animation]; 17 | 18 | //设置运动时间 19 | animation.duration = 0.35f; 20 | 21 | //设置运动type 22 | switch (animationType) { 23 | case AnimationTypeFade: 24 | animation.type = kCATransitionFade; 25 | break; 26 | 27 | case AnimationTypePush: 28 | animation.type = kCATransitionPush; 29 | break; 30 | 31 | case AnimationTypeReveal: 32 | animation.type = kCATransitionReveal; 33 | break; 34 | 35 | case AnimationTypeMoveIn: 36 | animation.type = kCATransitionMoveIn; 37 | break; 38 | 39 | case AnimationTypeCube: 40 | animation.type = @"cube"; 41 | break; 42 | 43 | case AnimationTypeSuckEffect: 44 | animation.type = @"suckEffect"; 45 | break; 46 | 47 | case AnimationTypeOglFlip: 48 | animation.type = @"oglFlip"; 49 | break; 50 | 51 | case AnimationTypeRippleEffect: 52 | animation.type = @"rippleEffect"; 53 | break; 54 | 55 | case AnimationTypePageCurl: 56 | animation.type = @"pageCurl"; 57 | break; 58 | 59 | case AnimationTypePageUnCurl: 60 | animation.type = @"pageUnCurl"; 61 | break; 62 | 63 | case AnimationTypeCameraIrisHollowOpen: 64 | animation.type = @"cameraIrisHollowOpen"; 65 | break; 66 | 67 | case AnimationTypeCameraIrisHollowClose: 68 | animation.type = @"cameraIrisHollowClose"; 69 | break; 70 | 71 | case AnimationTypeCurlDown: 72 | case AnimationTypeCurlUp: 73 | animation.type = @"pageCurl"; 74 | animation.subtype = subtype; 75 | break; 76 | 77 | case AnimationTypeFlipFromLeft: 78 | case AnimationTypeFlipFromRight: 79 | animation.type = @"oglFlip"; 80 | animation.subtype = subtype; 81 | break; 82 | 83 | default: 84 | break; 85 | } 86 | 87 | 88 | //设置子类 89 | if (subtype != nil) { 90 | animation.subtype = subtype; 91 | } 92 | 93 | //设置运动速度 94 | animation.timingFunction = UIViewAnimationOptionCurveEaseInOut; 95 | 96 | [[UIApplication sharedApplication].keyWindow.layer addAnimation:animation forKey:@"animation"]; 97 | } 98 | 99 | #pragma CATransition动画实现 100 | - (void) transitionWithType:(NSString *) type WithSubtype:(NSString *) subtype ForView : (UIView *) view 101 | { 102 | //创建CATransition对象 103 | CATransition *animation = [CATransition animation]; 104 | 105 | //设置运动时间 106 | animation.duration = 0.35f; 107 | 108 | //设置运动type 109 | animation.type = type; 110 | 111 | //设置子类 112 | if (subtype != nil) { 113 | animation.subtype = subtype; 114 | } 115 | 116 | //设置运动速度 117 | animation.timingFunction = UIViewAnimationOptionCurveEaseInOut; 118 | 119 | [view.layer addAnimation:animation forKey:@"animation"]; 120 | } 121 | 122 | 123 | @end 124 | -------------------------------------------------------------------------------- /XX3DRiseAndFall/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // XX3DRiseAndFall 4 | // 5 | // Created by inxx on 17/1/12. 6 | // Copyright © 2017年 GoGoGold E-Commerce Co.Ltd. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "UIViewController+XX3DFallAndRise.h" 11 | 12 | @interface ViewController : UIViewController 13 | 14 | 15 | @end 16 | 17 | -------------------------------------------------------------------------------- /XX3DRiseAndFall/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // XX3DRiseAndFall 4 | // 5 | // Created by inxx on 17/1/12. 6 | // Copyright © 2017年 GoGoGold E-Commerce Co.Ltd. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "UIViewController+XX3DFallAndRise.h" 11 | 12 | @interface ViewController () 13 | 14 | @end 15 | #define Width [UIScreen mainScreen].bounds.size.width 16 | #define Height [UIScreen mainScreen].bounds.size.height 17 | @implementation ViewController 18 | 19 | - (void)viewDidLoad { 20 | [super viewDidLoad]; 21 | 22 | UIButton *fallBtn = [[UIButton alloc] initWithFrame:CGRectMake(Width/2 - 30, 100, 60, 30)]; 23 | [fallBtn setTitle:@"下沉" forState:UIControlStateNormal]; 24 | [fallBtn setTitleColor:[UIColor blueColor] forState:UIControlStateNormal]; 25 | [fallBtn addTarget:self action:@selector(fall) forControlEvents:UIControlEventTouchUpInside]; 26 | [self.view addSubview:fallBtn]; 27 | 28 | UIButton *riseBtn = [[UIButton alloc] initWithFrame:CGRectMake(Width/2 - 30, Height - 100, 60, 30)]; 29 | [riseBtn setTitle:@"上升" forState:UIControlStateNormal]; 30 | [riseBtn setTitleColor:[UIColor blueColor] forState:UIControlStateNormal]; 31 | [riseBtn addTarget:self action:@selector(rise) forControlEvents:UIControlEventTouchUpInside]; 32 | [self.view addSubview:riseBtn]; 33 | } 34 | 35 | -(void)fall{ 36 | [self showWithDuration:0.5 transformType:TransformTypeM34]; 37 | } 38 | 39 | -(void)rise{ 40 | [self closeWithDuration:0.5 transformType:TransformTypeM34]; 41 | } 42 | 43 | - (void)didReceiveMemoryWarning { 44 | [super didReceiveMemoryWarning]; 45 | // Dispose of any resources that can be recreated. 46 | } 47 | 48 | @end 49 | -------------------------------------------------------------------------------- /XX3DRiseAndFall/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // XX3DRiseAndFall 4 | // 5 | // Created by inxx on 17/1/12. 6 | // Copyright © 2017年 GoGoGold E-Commerce Co.Ltd. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | --------------------------------------------------------------------------------