├── .DS_Store ├── .gitignore ├── AnimationDemo.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata └── AnimationDemo ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets ├── AppIcon.appiconset │ └── Contents.json ├── pic_ceshi1_biaoqian.imageset │ ├── Contents.json │ └── pic_ceshi1_biaoqian.png ├── pic_ceshi1_qipao(1).imageset │ ├── Contents.json │ └── pic_ceshi1_qipao(1).png ├── pic_ceshi1_qipao-1.imageset │ ├── Contents.json │ └── pic_ceshi1_qipao.png ├── pic_ceshi1_qipao.imageset │ ├── Contents.json │ └── pic_ceshi1_qipao.png ├── pic_ceshi1_wenzi.imageset │ ├── Contents.json │ └── pic_ceshi1_wenzi.png ├── pic_ceshi1_zi.imageset │ ├── Contents.json │ └── pic_ceshi1_zi.png ├── pic_ceshi2_biaoqian.imageset │ ├── Contents.json │ └── pic_ceshi2_biaoqian.png ├── pic_ceshi2_xingxing1.imageset │ ├── Contents.json │ └── pic_ceshi2_xingxing1.png ├── pic_ceshi2_xingxing2.imageset │ ├── Contents.json │ └── pic_ceshi2_xingxing2.png └── pic_ceshi3_biaoqian.imageset │ ├── Contents.json │ └── pic_ceshi3_biaoqian.png ├── Base.lproj ├── LaunchScreen.storyboard └── Main.storyboard ├── Info.plist ├── ViewController.h ├── ViewController.m └── main.m /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaojin1123/AnimationDemo/3788e70fbcd845966333604369be04f93302777b/.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 | *.xccheckout 23 | *.xcscmblueprint 24 | 25 | ## Obj-C/Swift specific 26 | *.hmap 27 | *.ipa 28 | *.dSYM.zip 29 | *.dSYM 30 | 31 | # CocoaPods 32 | # 33 | # We recommend against adding the Pods directory to your .gitignore. However 34 | # you should judge for yourself, the pros and cons are mentioned at: 35 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 36 | # 37 | # Pods/ 38 | 39 | # Carthage 40 | # 41 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 42 | # Carthage/Checkouts 43 | 44 | Carthage/Build 45 | 46 | # fastlane 47 | # 48 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 49 | # screenshots whenever they are needed. 50 | # For more information about the recommended setup visit: 51 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 52 | 53 | fastlane/report.xml 54 | fastlane/Preview.html 55 | fastlane/screenshots 56 | fastlane/test_output 57 | 58 | # Code Injection 59 | # 60 | # After new code Injection tools there's a generated folder /iOSInjectionProject 61 | # https://github.com/johnno1962/injectionforxcode 62 | 63 | iOSInjectionProject/ 64 | -------------------------------------------------------------------------------- /AnimationDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 0F5CC34E1ED3CA2C00C24D92 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 0F5CC34D1ED3CA2C00C24D92 /* main.m */; }; 11 | 0F5CC3511ED3CA2C00C24D92 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 0F5CC3501ED3CA2C00C24D92 /* AppDelegate.m */; }; 12 | 0F5CC3541ED3CA2C00C24D92 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 0F5CC3531ED3CA2C00C24D92 /* ViewController.m */; }; 13 | 0F5CC3571ED3CA2C00C24D92 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0F5CC3551ED3CA2C00C24D92 /* Main.storyboard */; }; 14 | 0F5CC3591ED3CA2C00C24D92 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0F5CC3581ED3CA2C00C24D92 /* Assets.xcassets */; }; 15 | 0F5CC35C1ED3CA2C00C24D92 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0F5CC35A1ED3CA2C00C24D92 /* LaunchScreen.storyboard */; }; 16 | /* End PBXBuildFile section */ 17 | 18 | /* Begin PBXFileReference section */ 19 | 0F5CC3491ED3CA2C00C24D92 /* AnimationDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = AnimationDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 20 | 0F5CC34D1ED3CA2C00C24D92 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 21 | 0F5CC34F1ED3CA2C00C24D92 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 22 | 0F5CC3501ED3CA2C00C24D92 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 23 | 0F5CC3521ED3CA2C00C24D92 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 24 | 0F5CC3531ED3CA2C00C24D92 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 25 | 0F5CC3561ED3CA2C00C24D92 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 26 | 0F5CC3581ED3CA2C00C24D92 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 27 | 0F5CC35B1ED3CA2C00C24D92 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 28 | 0F5CC35D1ED3CA2C00C24D92 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 29 | /* End PBXFileReference section */ 30 | 31 | /* Begin PBXFrameworksBuildPhase section */ 32 | 0F5CC3461ED3CA2C00C24D92 /* Frameworks */ = { 33 | isa = PBXFrameworksBuildPhase; 34 | buildActionMask = 2147483647; 35 | files = ( 36 | ); 37 | runOnlyForDeploymentPostprocessing = 0; 38 | }; 39 | /* End PBXFrameworksBuildPhase section */ 40 | 41 | /* Begin PBXGroup section */ 42 | 0F5CC3401ED3CA2C00C24D92 = { 43 | isa = PBXGroup; 44 | children = ( 45 | 0F5CC34B1ED3CA2C00C24D92 /* AnimationDemo */, 46 | 0F5CC34A1ED3CA2C00C24D92 /* Products */, 47 | ); 48 | sourceTree = ""; 49 | }; 50 | 0F5CC34A1ED3CA2C00C24D92 /* Products */ = { 51 | isa = PBXGroup; 52 | children = ( 53 | 0F5CC3491ED3CA2C00C24D92 /* AnimationDemo.app */, 54 | ); 55 | name = Products; 56 | sourceTree = ""; 57 | }; 58 | 0F5CC34B1ED3CA2C00C24D92 /* AnimationDemo */ = { 59 | isa = PBXGroup; 60 | children = ( 61 | 0F5CC34F1ED3CA2C00C24D92 /* AppDelegate.h */, 62 | 0F5CC3501ED3CA2C00C24D92 /* AppDelegate.m */, 63 | 0F5CC3521ED3CA2C00C24D92 /* ViewController.h */, 64 | 0F5CC3531ED3CA2C00C24D92 /* ViewController.m */, 65 | 0F5CC3551ED3CA2C00C24D92 /* Main.storyboard */, 66 | 0F5CC3581ED3CA2C00C24D92 /* Assets.xcassets */, 67 | 0F5CC35A1ED3CA2C00C24D92 /* LaunchScreen.storyboard */, 68 | 0F5CC35D1ED3CA2C00C24D92 /* Info.plist */, 69 | 0F5CC34C1ED3CA2C00C24D92 /* Supporting Files */, 70 | ); 71 | path = AnimationDemo; 72 | sourceTree = ""; 73 | }; 74 | 0F5CC34C1ED3CA2C00C24D92 /* Supporting Files */ = { 75 | isa = PBXGroup; 76 | children = ( 77 | 0F5CC34D1ED3CA2C00C24D92 /* main.m */, 78 | ); 79 | name = "Supporting Files"; 80 | sourceTree = ""; 81 | }; 82 | /* End PBXGroup section */ 83 | 84 | /* Begin PBXNativeTarget section */ 85 | 0F5CC3481ED3CA2C00C24D92 /* AnimationDemo */ = { 86 | isa = PBXNativeTarget; 87 | buildConfigurationList = 0F5CC3601ED3CA2C00C24D92 /* Build configuration list for PBXNativeTarget "AnimationDemo" */; 88 | buildPhases = ( 89 | 0F5CC3451ED3CA2C00C24D92 /* Sources */, 90 | 0F5CC3461ED3CA2C00C24D92 /* Frameworks */, 91 | 0F5CC3471ED3CA2C00C24D92 /* Resources */, 92 | ); 93 | buildRules = ( 94 | ); 95 | dependencies = ( 96 | ); 97 | name = AnimationDemo; 98 | productName = AnimationDemo; 99 | productReference = 0F5CC3491ED3CA2C00C24D92 /* AnimationDemo.app */; 100 | productType = "com.apple.product-type.application"; 101 | }; 102 | /* End PBXNativeTarget section */ 103 | 104 | /* Begin PBXProject section */ 105 | 0F5CC3411ED3CA2C00C24D92 /* Project object */ = { 106 | isa = PBXProject; 107 | attributes = { 108 | LastUpgradeCheck = 0830; 109 | ORGANIZATIONNAME = 11; 110 | TargetAttributes = { 111 | 0F5CC3481ED3CA2C00C24D92 = { 112 | CreatedOnToolsVersion = 8.3.2; 113 | DevelopmentTeam = A98BCWPX5P; 114 | ProvisioningStyle = Automatic; 115 | }; 116 | }; 117 | }; 118 | buildConfigurationList = 0F5CC3441ED3CA2C00C24D92 /* Build configuration list for PBXProject "AnimationDemo" */; 119 | compatibilityVersion = "Xcode 3.2"; 120 | developmentRegion = English; 121 | hasScannedForEncodings = 0; 122 | knownRegions = ( 123 | en, 124 | Base, 125 | ); 126 | mainGroup = 0F5CC3401ED3CA2C00C24D92; 127 | productRefGroup = 0F5CC34A1ED3CA2C00C24D92 /* Products */; 128 | projectDirPath = ""; 129 | projectRoot = ""; 130 | targets = ( 131 | 0F5CC3481ED3CA2C00C24D92 /* AnimationDemo */, 132 | ); 133 | }; 134 | /* End PBXProject section */ 135 | 136 | /* Begin PBXResourcesBuildPhase section */ 137 | 0F5CC3471ED3CA2C00C24D92 /* Resources */ = { 138 | isa = PBXResourcesBuildPhase; 139 | buildActionMask = 2147483647; 140 | files = ( 141 | 0F5CC35C1ED3CA2C00C24D92 /* LaunchScreen.storyboard in Resources */, 142 | 0F5CC3591ED3CA2C00C24D92 /* Assets.xcassets in Resources */, 143 | 0F5CC3571ED3CA2C00C24D92 /* Main.storyboard in Resources */, 144 | ); 145 | runOnlyForDeploymentPostprocessing = 0; 146 | }; 147 | /* End PBXResourcesBuildPhase section */ 148 | 149 | /* Begin PBXSourcesBuildPhase section */ 150 | 0F5CC3451ED3CA2C00C24D92 /* Sources */ = { 151 | isa = PBXSourcesBuildPhase; 152 | buildActionMask = 2147483647; 153 | files = ( 154 | 0F5CC3541ED3CA2C00C24D92 /* ViewController.m in Sources */, 155 | 0F5CC3511ED3CA2C00C24D92 /* AppDelegate.m in Sources */, 156 | 0F5CC34E1ED3CA2C00C24D92 /* main.m in Sources */, 157 | ); 158 | runOnlyForDeploymentPostprocessing = 0; 159 | }; 160 | /* End PBXSourcesBuildPhase section */ 161 | 162 | /* Begin PBXVariantGroup section */ 163 | 0F5CC3551ED3CA2C00C24D92 /* Main.storyboard */ = { 164 | isa = PBXVariantGroup; 165 | children = ( 166 | 0F5CC3561ED3CA2C00C24D92 /* Base */, 167 | ); 168 | name = Main.storyboard; 169 | sourceTree = ""; 170 | }; 171 | 0F5CC35A1ED3CA2C00C24D92 /* LaunchScreen.storyboard */ = { 172 | isa = PBXVariantGroup; 173 | children = ( 174 | 0F5CC35B1ED3CA2C00C24D92 /* Base */, 175 | ); 176 | name = LaunchScreen.storyboard; 177 | sourceTree = ""; 178 | }; 179 | /* End PBXVariantGroup section */ 180 | 181 | /* Begin XCBuildConfiguration section */ 182 | 0F5CC35E1ED3CA2C00C24D92 /* Debug */ = { 183 | isa = XCBuildConfiguration; 184 | buildSettings = { 185 | ALWAYS_SEARCH_USER_PATHS = NO; 186 | CLANG_ANALYZER_NONNULL = YES; 187 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 188 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 189 | CLANG_CXX_LIBRARY = "libc++"; 190 | CLANG_ENABLE_MODULES = YES; 191 | CLANG_ENABLE_OBJC_ARC = YES; 192 | CLANG_WARN_BOOL_CONVERSION = YES; 193 | CLANG_WARN_CONSTANT_CONVERSION = YES; 194 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 195 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 196 | CLANG_WARN_EMPTY_BODY = YES; 197 | CLANG_WARN_ENUM_CONVERSION = YES; 198 | CLANG_WARN_INFINITE_RECURSION = YES; 199 | CLANG_WARN_INT_CONVERSION = YES; 200 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 201 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 202 | CLANG_WARN_UNREACHABLE_CODE = YES; 203 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 204 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 205 | COPY_PHASE_STRIP = NO; 206 | DEBUG_INFORMATION_FORMAT = dwarf; 207 | ENABLE_STRICT_OBJC_MSGSEND = YES; 208 | ENABLE_TESTABILITY = YES; 209 | GCC_C_LANGUAGE_STANDARD = gnu99; 210 | GCC_DYNAMIC_NO_PIC = NO; 211 | GCC_NO_COMMON_BLOCKS = YES; 212 | GCC_OPTIMIZATION_LEVEL = 0; 213 | GCC_PREPROCESSOR_DEFINITIONS = ( 214 | "DEBUG=1", 215 | "$(inherited)", 216 | ); 217 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 218 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 219 | GCC_WARN_UNDECLARED_SELECTOR = YES; 220 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 221 | GCC_WARN_UNUSED_FUNCTION = YES; 222 | GCC_WARN_UNUSED_VARIABLE = YES; 223 | IPHONEOS_DEPLOYMENT_TARGET = 10.3; 224 | MTL_ENABLE_DEBUG_INFO = YES; 225 | ONLY_ACTIVE_ARCH = YES; 226 | SDKROOT = iphoneos; 227 | }; 228 | name = Debug; 229 | }; 230 | 0F5CC35F1ED3CA2C00C24D92 /* Release */ = { 231 | isa = XCBuildConfiguration; 232 | buildSettings = { 233 | ALWAYS_SEARCH_USER_PATHS = NO; 234 | CLANG_ANALYZER_NONNULL = YES; 235 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 236 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 237 | CLANG_CXX_LIBRARY = "libc++"; 238 | CLANG_ENABLE_MODULES = YES; 239 | CLANG_ENABLE_OBJC_ARC = YES; 240 | CLANG_WARN_BOOL_CONVERSION = YES; 241 | CLANG_WARN_CONSTANT_CONVERSION = YES; 242 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 243 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 244 | CLANG_WARN_EMPTY_BODY = YES; 245 | CLANG_WARN_ENUM_CONVERSION = YES; 246 | CLANG_WARN_INFINITE_RECURSION = YES; 247 | CLANG_WARN_INT_CONVERSION = YES; 248 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 249 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 250 | CLANG_WARN_UNREACHABLE_CODE = YES; 251 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 252 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 253 | COPY_PHASE_STRIP = NO; 254 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 255 | ENABLE_NS_ASSERTIONS = NO; 256 | ENABLE_STRICT_OBJC_MSGSEND = YES; 257 | GCC_C_LANGUAGE_STANDARD = gnu99; 258 | GCC_NO_COMMON_BLOCKS = YES; 259 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 260 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 261 | GCC_WARN_UNDECLARED_SELECTOR = YES; 262 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 263 | GCC_WARN_UNUSED_FUNCTION = YES; 264 | GCC_WARN_UNUSED_VARIABLE = YES; 265 | IPHONEOS_DEPLOYMENT_TARGET = 10.3; 266 | MTL_ENABLE_DEBUG_INFO = NO; 267 | SDKROOT = iphoneos; 268 | VALIDATE_PRODUCT = YES; 269 | }; 270 | name = Release; 271 | }; 272 | 0F5CC3611ED3CA2C00C24D92 /* Debug */ = { 273 | isa = XCBuildConfiguration; 274 | buildSettings = { 275 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 276 | DEVELOPMENT_TEAM = A98BCWPX5P; 277 | INFOPLIST_FILE = AnimationDemo/Info.plist; 278 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 279 | PRODUCT_BUNDLE_IDENTIFIER = com.ios.AnimationDemo; 280 | PRODUCT_NAME = "$(TARGET_NAME)"; 281 | }; 282 | name = Debug; 283 | }; 284 | 0F5CC3621ED3CA2C00C24D92 /* Release */ = { 285 | isa = XCBuildConfiguration; 286 | buildSettings = { 287 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 288 | DEVELOPMENT_TEAM = A98BCWPX5P; 289 | INFOPLIST_FILE = AnimationDemo/Info.plist; 290 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 291 | PRODUCT_BUNDLE_IDENTIFIER = com.ios.AnimationDemo; 292 | PRODUCT_NAME = "$(TARGET_NAME)"; 293 | }; 294 | name = Release; 295 | }; 296 | /* End XCBuildConfiguration section */ 297 | 298 | /* Begin XCConfigurationList section */ 299 | 0F5CC3441ED3CA2C00C24D92 /* Build configuration list for PBXProject "AnimationDemo" */ = { 300 | isa = XCConfigurationList; 301 | buildConfigurations = ( 302 | 0F5CC35E1ED3CA2C00C24D92 /* Debug */, 303 | 0F5CC35F1ED3CA2C00C24D92 /* Release */, 304 | ); 305 | defaultConfigurationIsVisible = 0; 306 | defaultConfigurationName = Release; 307 | }; 308 | 0F5CC3601ED3CA2C00C24D92 /* Build configuration list for PBXNativeTarget "AnimationDemo" */ = { 309 | isa = XCConfigurationList; 310 | buildConfigurations = ( 311 | 0F5CC3611ED3CA2C00C24D92 /* Debug */, 312 | 0F5CC3621ED3CA2C00C24D92 /* Release */, 313 | ); 314 | defaultConfigurationIsVisible = 0; 315 | }; 316 | /* End XCConfigurationList section */ 317 | }; 318 | rootObject = 0F5CC3411ED3CA2C00C24D92 /* Project object */; 319 | } 320 | -------------------------------------------------------------------------------- /AnimationDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /AnimationDemo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // AnimationDemo 4 | // 5 | // Created by 11 on 2017/5/23. 6 | // Copyright © 2017年 11. 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 | -------------------------------------------------------------------------------- /AnimationDemo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // AnimationDemo 4 | // 5 | // Created by 11 on 2017/5/23. 6 | // Copyright © 2017年 11. 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 | 24 | - (void)applicationWillResignActive:(UIApplication *)application { 25 | // 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. 26 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 27 | } 28 | 29 | 30 | - (void)applicationDidEnterBackground:(UIApplication *)application { 31 | // 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. 32 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 33 | } 34 | 35 | 36 | - (void)applicationWillEnterForeground:(UIApplication *)application { 37 | [[NSNotificationCenter defaultCenter]postNotificationName:@"APPEnterForeground" object:nil]; 38 | } 39 | 40 | 41 | - (void)applicationDidBecomeActive:(UIApplication *)application { 42 | // 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. 43 | } 44 | 45 | 46 | - (void)applicationWillTerminate:(UIApplication *)application { 47 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 48 | } 49 | 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /AnimationDemo/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 | "info" : { 45 | "version" : 1, 46 | "author" : "xcode" 47 | } 48 | } -------------------------------------------------------------------------------- /AnimationDemo/Assets.xcassets/pic_ceshi1_biaoqian.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "pic_ceshi1_biaoqian.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /AnimationDemo/Assets.xcassets/pic_ceshi1_biaoqian.imageset/pic_ceshi1_biaoqian.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaojin1123/AnimationDemo/3788e70fbcd845966333604369be04f93302777b/AnimationDemo/Assets.xcassets/pic_ceshi1_biaoqian.imageset/pic_ceshi1_biaoqian.png -------------------------------------------------------------------------------- /AnimationDemo/Assets.xcassets/pic_ceshi1_qipao(1).imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "pic_ceshi1_qipao(1).png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /AnimationDemo/Assets.xcassets/pic_ceshi1_qipao(1).imageset/pic_ceshi1_qipao(1).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaojin1123/AnimationDemo/3788e70fbcd845966333604369be04f93302777b/AnimationDemo/Assets.xcassets/pic_ceshi1_qipao(1).imageset/pic_ceshi1_qipao(1).png -------------------------------------------------------------------------------- /AnimationDemo/Assets.xcassets/pic_ceshi1_qipao-1.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "pic_ceshi1_qipao.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /AnimationDemo/Assets.xcassets/pic_ceshi1_qipao-1.imageset/pic_ceshi1_qipao.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaojin1123/AnimationDemo/3788e70fbcd845966333604369be04f93302777b/AnimationDemo/Assets.xcassets/pic_ceshi1_qipao-1.imageset/pic_ceshi1_qipao.png -------------------------------------------------------------------------------- /AnimationDemo/Assets.xcassets/pic_ceshi1_qipao.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "pic_ceshi1_qipao.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /AnimationDemo/Assets.xcassets/pic_ceshi1_qipao.imageset/pic_ceshi1_qipao.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaojin1123/AnimationDemo/3788e70fbcd845966333604369be04f93302777b/AnimationDemo/Assets.xcassets/pic_ceshi1_qipao.imageset/pic_ceshi1_qipao.png -------------------------------------------------------------------------------- /AnimationDemo/Assets.xcassets/pic_ceshi1_wenzi.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "pic_ceshi1_wenzi.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /AnimationDemo/Assets.xcassets/pic_ceshi1_wenzi.imageset/pic_ceshi1_wenzi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaojin1123/AnimationDemo/3788e70fbcd845966333604369be04f93302777b/AnimationDemo/Assets.xcassets/pic_ceshi1_wenzi.imageset/pic_ceshi1_wenzi.png -------------------------------------------------------------------------------- /AnimationDemo/Assets.xcassets/pic_ceshi1_zi.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "pic_ceshi1_zi.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /AnimationDemo/Assets.xcassets/pic_ceshi1_zi.imageset/pic_ceshi1_zi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaojin1123/AnimationDemo/3788e70fbcd845966333604369be04f93302777b/AnimationDemo/Assets.xcassets/pic_ceshi1_zi.imageset/pic_ceshi1_zi.png -------------------------------------------------------------------------------- /AnimationDemo/Assets.xcassets/pic_ceshi2_biaoqian.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "pic_ceshi2_biaoqian.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /AnimationDemo/Assets.xcassets/pic_ceshi2_biaoqian.imageset/pic_ceshi2_biaoqian.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaojin1123/AnimationDemo/3788e70fbcd845966333604369be04f93302777b/AnimationDemo/Assets.xcassets/pic_ceshi2_biaoqian.imageset/pic_ceshi2_biaoqian.png -------------------------------------------------------------------------------- /AnimationDemo/Assets.xcassets/pic_ceshi2_xingxing1.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "pic_ceshi2_xingxing1.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /AnimationDemo/Assets.xcassets/pic_ceshi2_xingxing1.imageset/pic_ceshi2_xingxing1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaojin1123/AnimationDemo/3788e70fbcd845966333604369be04f93302777b/AnimationDemo/Assets.xcassets/pic_ceshi2_xingxing1.imageset/pic_ceshi2_xingxing1.png -------------------------------------------------------------------------------- /AnimationDemo/Assets.xcassets/pic_ceshi2_xingxing2.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "pic_ceshi2_xingxing2.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /AnimationDemo/Assets.xcassets/pic_ceshi2_xingxing2.imageset/pic_ceshi2_xingxing2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaojin1123/AnimationDemo/3788e70fbcd845966333604369be04f93302777b/AnimationDemo/Assets.xcassets/pic_ceshi2_xingxing2.imageset/pic_ceshi2_xingxing2.png -------------------------------------------------------------------------------- /AnimationDemo/Assets.xcassets/pic_ceshi3_biaoqian.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "pic_ceshi3_biaoqian.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /AnimationDemo/Assets.xcassets/pic_ceshi3_biaoqian.imageset/pic_ceshi3_biaoqian.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaojin1123/AnimationDemo/3788e70fbcd845966333604369be04f93302777b/AnimationDemo/Assets.xcassets/pic_ceshi3_biaoqian.imageset/pic_ceshi3_biaoqian.png -------------------------------------------------------------------------------- /AnimationDemo/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 | -------------------------------------------------------------------------------- /AnimationDemo/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 | -------------------------------------------------------------------------------- /AnimationDemo/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 | 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 | 38 | 39 | -------------------------------------------------------------------------------- /AnimationDemo/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // AnimationDemo 4 | // 5 | // Created by 11 on 2017/5/23. 6 | // Copyright © 2017年 11. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /AnimationDemo/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // AnimationDemo 4 | // 5 | // Created by 11 on 2017/5/23. 6 | // Copyright © 2017年 11. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | 11 | #define kTAG_BASE_VALUE 90 12 | 13 | 14 | @interface ViewController () 15 | @property (weak, nonatomic) IBOutlet UIView *firstView; 16 | @property (weak, nonatomic) IBOutlet UIView *secondView; 17 | @property (weak, nonatomic) IBOutlet UIView *threeView; 18 | @property (weak, nonatomic) IBOutlet UIView *fourView; 19 | 20 | @end 21 | 22 | @implementation ViewController 23 | 24 | - (void)viewDidLoad { 25 | [super viewDidLoad]; 26 | [self initSubViews]; 27 | } 28 | 29 | - (void)viewWillAppear:(BOOL)animated{ 30 | [super viewWillAppear:animated]; 31 | 32 | //离屏后会remove animation,这里重新添加 33 | [self restartAnimation]; 34 | //程序从后台进入激活状态需要重新添加Animation 35 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(restartAnimation) name:@"APPEnterForeground" object:nil]; 36 | } 37 | 38 | - (void)viewWillDisappear:(BOOL)animated{ 39 | [super viewWillDisappear:animated]; 40 | [[NSNotificationCenter defaultCenter] removeObserver:self name:@"APPEnterForeground" object:nil]; 41 | } 42 | 43 | - (void)initSubViews{ 44 | [self initUI]; 45 | [self restartAnimation]; 46 | } 47 | -(void)initUI{ 48 | //1 49 | CGRect frame = self.firstView.bounds; 50 | UIImageView *imageView = [self createImageViewWithFrame:frame tag:kTAG_BASE_VALUE named:@"pic_ceshi2_biaoqian"]; 51 | imageView.layer.anchorPoint = CGPointMake(28.5/ 45.0, 16/ 45.0); 52 | imageView.frame = frame; 53 | [self.firstView addSubview:imageView]; 54 | imageView = [self createImageViewWithFrame:frame tag:kTAG_BASE_VALUE+1 named:@"pic_ceshi2_xingxing1"]; 55 | [self.firstView addSubview:imageView]; 56 | imageView = [self createImageViewWithFrame:frame tag:kTAG_BASE_VALUE+2 named:@"pic_ceshi2_xingxing2"]; 57 | [self.firstView addSubview:imageView]; 58 | 59 | //2 60 | frame = self.secondView.bounds; 61 | imageView = [self createImageViewWithFrame:frame tag:kTAG_BASE_VALUE named:@"pic_ceshi1_biaoqian"]; 62 | [self.secondView addSubview:imageView]; 63 | 64 | frame = CGRectMake(45 - 18, 0, 18, 19.5); 65 | UIView *contentView = [[UIView alloc]init]; 66 | contentView.layer.anchorPoint = CGPointMake(0, 1); 67 | contentView.frame = frame; 68 | contentView.tag = kTAG_BASE_VALUE + 10; 69 | [self.secondView addSubview:contentView]; 70 | imageView = [self createImageViewWithFrame:contentView.bounds tag:kTAG_BASE_VALUE named:@"pic_ceshi1_qipao(1)"]; 71 | [contentView addSubview:imageView]; 72 | imageView = [self createImageViewWithFrame:contentView.bounds tag:kTAG_BASE_VALUE+1 named:@"pic_ceshi1_zi"]; 73 | imageView.layer.anchorPoint = CGPointMake(0, 1); 74 | imageView.frame = contentView.bounds; 75 | [contentView addSubview:imageView]; 76 | 77 | //3 78 | frame = self.threeView.bounds; 79 | imageView = [self createImageViewWithFrame:frame tag:kTAG_BASE_VALUE named:@"pic_ceshi3_biaoqian"]; 80 | imageView.layer.anchorPoint = CGPointMake(0.5, 12/ 45.0); 81 | imageView.frame = frame; 82 | [self.threeView addSubview:imageView]; 83 | 84 | //4 85 | frame = self.fourView.bounds; 86 | imageView = [self createImageViewWithFrame:frame tag:kTAG_BASE_VALUE named:@"pic_ceshi2_biaoqian"]; 87 | [self.fourView addSubview:imageView]; 88 | imageView = [self createImageViewWithFrame:frame tag:kTAG_BASE_VALUE+1 named:@"pic_ceshi2_xingxing1"]; 89 | [self.fourView addSubview:imageView]; 90 | imageView = [self createImageViewWithFrame:frame tag:kTAG_BASE_VALUE+2 named:@"pic_ceshi2_xingxing2"]; 91 | [self.fourView addSubview:imageView]; 92 | 93 | } 94 | 95 | - (UIImageView *)createImageViewWithFrame:(CGRect)frame tag:(NSInteger)tag named:(NSString *)name{ 96 | UIImageView *imageView = [[UIImageView alloc]initWithFrame:frame]; 97 | imageView.tag = tag; 98 | imageView.image = [UIImage imageNamed:name]; 99 | return imageView; 100 | } 101 | - (void)restartAnimation{ 102 | [self startAnimationForFirstView]; 103 | [self startAnimationForSecodView]; 104 | [self startAnimationForThirdView]; 105 | [self startAnimationForFourthView]; 106 | } 107 | 108 | 109 | - (void)startAnimationForFirstView{ 110 | id fromValue = [NSNumber numberWithFloat:-M_PI/ 10.0]; 111 | id toValue = [NSNumber numberWithFloat:M_PI/ 10.0]; 112 | UIImageView *imageView = [self.firstView viewWithTag:kTAG_BASE_VALUE]; 113 | [self animationWithView:imageView keyPath:@"transform.rotation.z" fromValue:fromValue toValue:toValue]; 114 | 115 | fromValue = @1; 116 | toValue = @0.1; 117 | imageView = [self.firstView viewWithTag:kTAG_BASE_VALUE + 1]; 118 | [self animationWithView:imageView keyPath:@"opacity" fromValue:fromValue toValue:toValue]; 119 | 120 | fromValue = @0.1; 121 | toValue = @1; 122 | imageView = [self.firstView viewWithTag:kTAG_BASE_VALUE + 2]; 123 | [self animationWithView:imageView keyPath:@"opacity" fromValue:fromValue toValue:toValue]; 124 | } 125 | 126 | - (void)startAnimationForSecodView{ 127 | id fromValue = [NSNumber numberWithFloat:-M_PI/ 12.0]; 128 | id toValue = [NSNumber numberWithFloat:0]; 129 | NSString *rAnimationKey = @"transform.rotation.z"; 130 | NSString *sAnimationKey = @"transform.scale"; 131 | 132 | CAAnimation *rAnimation = [self createSAnimationWithKeyPath:rAnimationKey fromValue:fromValue toValue:toValue]; 133 | CAAnimation *sAnimation = [self createSAnimationWithKeyPath:sAnimationKey fromValue:@0.9 toValue:@1]; 134 | 135 | CAAnimationGroup *animationGroup = [CAAnimationGroup animation]; 136 | animationGroup.repeatCount = HUGE_VALF; 137 | animationGroup.duration = 1; 138 | animationGroup.autoreverses = YES; 139 | animationGroup.animations = @[rAnimation, sAnimation]; 140 | UIView *contentView = [self.secondView viewWithTag:kTAG_BASE_VALUE + 10]; 141 | [contentView.layer addAnimation:animationGroup forKey:nil]; 142 | 143 | UIImageView *imageView = [contentView viewWithTag:kTAG_BASE_VALUE + 1]; 144 | fromValue = [NSNumber numberWithFloat:0]; 145 | toValue = [NSNumber numberWithFloat:-M_PI/ 30.0]; 146 | CAAnimation *ziAnimation = [self createKAnimationWithKeyPath:rAnimationKey fromValue:fromValue toValue:toValue]; 147 | [imageView.layer addAnimation:ziAnimation forKey:nil]; 148 | } 149 | 150 | - (void)startAnimationForThirdView{ 151 | id fromValue = [NSNumber numberWithFloat:-M_PI/ 10.0]; 152 | id toValue = [NSNumber numberWithFloat:M_PI/ 10.0]; 153 | UIImageView *imageView = [self.threeView viewWithTag:kTAG_BASE_VALUE]; 154 | [self animationWithView:imageView keyPath:@"transform.rotation.z" fromValue:fromValue toValue:toValue]; 155 | } 156 | 157 | - (void)startAnimationForFourthView{ 158 | UIImageView *imageView = [self.fourView viewWithTag:kTAG_BASE_VALUE]; 159 | id fromValue = [NSValue valueWithCGPoint:CGPointMake(45/ 2 + 1.5, 45/ 2 + 1.5)]; 160 | id toValue = [NSValue valueWithCGPoint:CGPointMake(45/ 2 - 1.5, 45/ 2 - 1.5)]; 161 | [self animationWithView:imageView keyPath:@"position" fromValue:fromValue toValue:toValue duration:0.6]; 162 | 163 | imageView = [self.fourView viewWithTag:kTAG_BASE_VALUE + 1]; 164 | fromValue = @1; 165 | toValue = @0.1; 166 | [self animationWithView:imageView keyPath:@"opacity" fromValue:fromValue toValue:toValue duration:0.6]; 167 | 168 | imageView = [self.fourView viewWithTag:kTAG_BASE_VALUE + 2]; 169 | fromValue = @0.1; 170 | toValue = @1; 171 | [self animationWithView:imageView keyPath:@"opacity" fromValue:fromValue toValue:toValue duration:0.6]; 172 | } 173 | 174 | - (void)animationWithView:(UIView *)view keyPath:(NSString *)keyPath fromValue:(id)fromValue toValue:(id)toValue{ 175 | CAAnimation *animation = [self createAnimationWithKeyPath:keyPath fromValue:fromValue toValue:toValue]; 176 | [view.layer addAnimation:animation forKey:nil]; 177 | } 178 | 179 | - (void)animationWithView:(UIView *)view 180 | keyPath:(NSString *)keyPath 181 | fromValue:(id)fromValue 182 | toValue:(id)toValue 183 | duration:(CGFloat)duration{ 184 | CAAnimation *animation = [self createAnimationWithKeyPath:keyPath fromValue:fromValue toValue:toValue]; 185 | animation.duration = duration; 186 | [view.layer addAnimation:animation forKey:nil]; 187 | } 188 | 189 | - (CAAnimation *)createSAnimationWithKeyPath:(NSString *)keyPath fromValue:(id)fromValue toValue:(id)toValue{ 190 | CAMediaTimingFunction *mediaTiming = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]; 191 | 192 | CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:keyPath]; 193 | animation.timingFunction = mediaTiming; 194 | animation.duration = 0.2; 195 | animation.repeatCount = 1; 196 | animation.fromValue = fromValue;// 起始角度 197 | animation.toValue = toValue; // 终止角度 198 | //kCAFillModeRemoved | kCAFillModeForwards | kCAFillModeBoth | kCAFillModeBackwards 199 | animation.fillMode = kCAFillModeForwards; 200 | animation.removedOnCompletion = NO; 201 | return animation; 202 | } 203 | 204 | - (CAAnimation *)createKAnimationWithKeyPath:(NSString *)keyPath fromValue:(id)fromValue toValue:(id)toValue{ 205 | CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:keyPath]; 206 | animation.duration = 2; 207 | animation.calculationMode = kCAAnimationCubic; 208 | animation.repeatCount = HUGE_VALF; 209 | animation.values = @[fromValue, fromValue, @(-[toValue floatValue]/ 2.0), toValue, fromValue, fromValue]; 210 | animation.keyTimes = @[@(0), @(0.075), @(0.09), @(0.13), @(0.16), @(1)]; 211 | return animation; 212 | } 213 | 214 | - (CAAnimation *)createAnimationWithKeyPath:(NSString *)keyPath fromValue:(id)fromValue toValue:(id)toValue{ 215 | CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:keyPath]; 216 | animation.duration = 1.5; // 持续时间 217 | 218 | CAMediaTimingFunction *mediaTiming = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; 219 | animation.timingFunction = mediaTiming; 220 | animation.repeatCount = HUGE_VALF; // 重复次数 221 | animation.fromValue = fromValue;// 起始角度 222 | animation.toValue = toValue; // 终止角度 223 | animation.autoreverses = YES; 224 | return animation; 225 | } 226 | 227 | 228 | @end 229 | -------------------------------------------------------------------------------- /AnimationDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // AnimationDemo 4 | // 5 | // Created by 11 on 2017/5/23. 6 | // Copyright © 2017年 11. 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 | --------------------------------------------------------------------------------