├── a-diligent-worm.gif
├── a-diligent-worm-in-iOS.gif
├── CCWormHUDDemo
├── CCWormHUDDemo.xcodeproj
│ ├── xcuserdata
│ │ └── Cocos.xcuserdatad
│ │ │ ├── xcdebugger
│ │ │ └── Breakpoints_v2.xcbkptlist
│ │ │ └── xcschemes
│ │ │ ├── xcschememanagement.plist
│ │ │ └── CCWormHUDDemo.xcscheme
│ ├── project.xcworkspace
│ │ └── contents.xcworkspacedata
│ └── project.pbxproj
└── CCWormHUDDemo
│ ├── ViewController.h
│ ├── AppDelegate.h
│ ├── main.m
│ ├── ThirdLib
│ ├── CCWormView.h
│ └── CCWormView.m
│ ├── Assets.xcassets
│ └── AppIcon.appiconset
│ │ └── Contents.json
│ ├── ViewController.m
│ ├── Info.plist
│ ├── Base.lproj
│ ├── LaunchScreen.storyboard
│ └── Main.storyboard
│ └── AppDelegate.m
├── Source
├── CCWormHUD.xcodeproj
│ ├── project.xcworkspace
│ │ └── contents.xcworkspacedata
│ ├── xcuserdata
│ │ └── Cocos.xcuserdatad
│ │ │ └── xcschemes
│ │ │ ├── xcschememanagement.plist
│ │ │ └── CCWormHUD.xcscheme
│ └── project.pbxproj
└── CCWormHUD
│ ├── ViewController.h
│ ├── AppDelegate.h
│ ├── main.m
│ ├── Classes
│ ├── CCWormView.h
│ └── CCWormView.m
│ ├── Assets.xcassets
│ └── AppIcon.appiconset
│ │ └── Contents.json
│ ├── ViewController.m
│ ├── Info.plist
│ ├── Base.lproj
│ ├── LaunchScreen.storyboard
│ └── Main.storyboard
│ └── AppDelegate.m
├── .gitignore
├── README.md
└── LICENSE.txt
/a-diligent-worm.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cocos543/CCWormHUD/HEAD/a-diligent-worm.gif
--------------------------------------------------------------------------------
/a-diligent-worm-in-iOS.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cocos543/CCWormHUD/HEAD/a-diligent-worm-in-iOS.gif
--------------------------------------------------------------------------------
/CCWormHUDDemo/CCWormHUDDemo.xcodeproj/xcuserdata/Cocos.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
--------------------------------------------------------------------------------
/Source/CCWormHUD.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/CCWormHUDDemo/CCWormHUDDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Source/CCWormHUD/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // CCWormHUD
4 | //
5 | // Created by Cocos on 16/3/17.
6 | // Copyright © 2016年 Cocos. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/CCWormHUDDemo/CCWormHUDDemo/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // CCWormHUDDemo
4 | //
5 | // Created by 郑克明 on 16/3/21.
6 | // Copyright © 2016年 Cocos. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/Source/CCWormHUD/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // CCWormHUD
4 | //
5 | // Created by Cocos on 16/3/17.
6 | // Copyright © 2016年 Cocos. 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 |
--------------------------------------------------------------------------------
/CCWormHUDDemo/CCWormHUDDemo/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // CCWormHUDDemo
4 | //
5 | // Created by 郑克明 on 16/3/21.
6 | // Copyright © 2016年 Cocos. 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 |
--------------------------------------------------------------------------------
/Source/CCWormHUD/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // CCWormHUD
4 | //
5 | // Created by Cocos on 16/3/17.
6 | // Copyright © 2016年 Cocos. 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 |
--------------------------------------------------------------------------------
/CCWormHUDDemo/CCWormHUDDemo/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // CCWormHUDDemo
4 | //
5 | // Created by 郑克明 on 16/3/21.
6 | // Copyright © 2016年 Cocos. 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 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Xcode
2 | .DS_Store
3 | Build
4 | */build/*
5 | *.pbxuser
6 | !default.pbxuser
7 | *.mode1v3
8 | !default.mode1v3
9 | *.mode2v3
10 | !default.mode2v3
11 | *.perspectivev3
12 | !default.perspectivev3
13 | xcuserdata
14 | profile
15 | *.moved-aside
16 | DerivedData
17 | .idea/
18 | *.hmap
19 | *.xccheckout
20 | *.xcworkspace
21 | !default.xcworkspace
22 | include/
23 | lib/
24 | Excalibur/scripts/
25 | UmengAnalytics/
26 | UMengFeedback/
27 |
28 | #CocoaPods
29 | Pods
30 | *.lock
31 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # CCWormHUD
2 | 壹個指示器,仿照蟲子運動的方式執行動畫.
3 |
4 | **詳細教程**
5 | [用代碼來實現妳喜歡的動畫效果 — 蟲兒跑](http://blog.cocosdever.com/2016/03/21/iOS-animation-design-of-the-worm-run)
6 |
7 | **參照原型**
8 | 
9 |
10 | **實現效果**
11 |
12 | 
13 |
14 |
15 |
16 |
17 | # CCWormHUD
18 | 一个指示器,仿照虫子运动的方式执行动画.
19 |
20 | **详细教程**
21 | [用代码来实现你喜欢的动画效果 — 虫儿跑](http://blog.cocosdever.com/2016/03/21/iOS-animation-design-of-the-worm-run)
22 |
23 | **参照原型**
24 | 
25 |
26 | **实现效果**
27 |
28 | 
29 |
--------------------------------------------------------------------------------
/Source/CCWormHUD.xcodeproj/xcuserdata/Cocos.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | CCWormHUD.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | ED0D1C291C9A8A76001B8138
16 |
17 | primary
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/Source/CCWormHUD/Classes/CCWormView.h:
--------------------------------------------------------------------------------
1 | //
2 | // CCWormView.h
3 | // CCWormHUD
4 | //
5 | // Created by Cocos on 16/3/17.
6 | // Copyright © 2016年 Cocos. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | //指示器类型
12 | typedef NS_ENUM(NSInteger, CCWormHUDStyle)
13 | {
14 | CCWormHUDStyleLarge, // 80 * 80
15 | CCWormHUDStyleNormal // 40 * 40
16 | };
17 |
18 | @interface CCWormView : UIView
19 |
20 | /**
21 | * 指示器状态
22 | */
23 | @property (nonatomic) BOOL isShowing;
24 |
25 | +(instancetype)wormHUDWithStyle:(CCWormHUDStyle)style toView:(UIView *)toView;
26 | -(void)startLodingWormHUD;
27 | -(void)endLodingWormHUD;
28 | @end
29 |
--------------------------------------------------------------------------------
/CCWormHUDDemo/CCWormHUDDemo/ThirdLib/CCWormView.h:
--------------------------------------------------------------------------------
1 | //
2 | // CCWormView.h
3 | // CCWormHUD
4 | //
5 | // Created by 郑克明 on 16/3/17.
6 | // Copyright © 2016年 Cocos. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | //指示器类型
12 | typedef NS_ENUM(NSInteger, CCWormHUDStyle)
13 | {
14 | CCWormHUDStyleLarge, // 80 * 80
15 | CCWormHUDStyleNormal // 40 * 40
16 | };
17 |
18 | @interface CCWormView : UIView
19 |
20 | /**
21 | * 指示器状态
22 | */
23 | @property (nonatomic) BOOL isShowing;
24 |
25 | +(instancetype)wormHUDWithStyle:(CCWormHUDStyle)style toView:(UIView *)toView;
26 | -(void)startLodingWormHUD;
27 | -(void)endLodingWormHUD;
28 | @end
29 |
--------------------------------------------------------------------------------
/CCWormHUDDemo/CCWormHUDDemo.xcodeproj/xcuserdata/Cocos.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | CCWormHUDDemo.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | EDC7EFE51C9FD17000AB1EF6
16 |
17 | primary
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/Source/CCWormHUD/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 | }
--------------------------------------------------------------------------------
/CCWormHUDDemo/CCWormHUDDemo/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 | }
--------------------------------------------------------------------------------
/Source/CCWormHUD/ViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.m
3 | // CCWormHUD
4 | //
5 | // Created by Cocos on 16/3/17.
6 | // Copyright © 2016年 Cocos. All rights reserved.
7 | //
8 |
9 | #import "ViewController.h"
10 | #import "CCWormView.h"
11 |
12 | @interface ViewController ()
13 | @property (nonatomic,strong) CCWormView *ccView;
14 | @end
15 |
16 | @implementation ViewController
17 |
18 | - (void)viewDidLoad {
19 | [super viewDidLoad];
20 | CCWormView *wormView = [CCWormView wormHUDWithStyle:CCWormHUDStyleLarge toView:self.view];
21 | self.ccView = wormView;
22 | }
23 |
24 | - (void)didReceiveMemoryWarning {
25 | [super didReceiveMemoryWarning];
26 | }
27 |
28 | - (IBAction)showOrHide:(id)sender {
29 | if (self.ccView.isShowing == NO) {
30 | [self.ccView startLodingWormHUD];
31 | }else{
32 | [self.ccView endLodingWormHUD];
33 | }
34 | }
35 |
36 | @end
37 |
--------------------------------------------------------------------------------
/CCWormHUDDemo/CCWormHUDDemo/ViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.m
3 | // CCWormHUDDemo
4 | //
5 | // Created by 郑克明 on 16/3/21.
6 | // Copyright © 2016年 Cocos. All rights reserved.
7 | //
8 |
9 | #import "ViewController.h"
10 | #import "CCWormView.h"
11 |
12 | @interface ViewController ()
13 | @property (nonatomic,strong) CCWormView *ccView;
14 | @end
15 |
16 | @implementation ViewController
17 |
18 | - (void)viewDidLoad {
19 | [super viewDidLoad];
20 | CCWormView *wormView = [CCWormView wormHUDWithStyle:CCWormHUDStyleLarge toView:self.view];
21 | self.ccView = wormView;
22 | }
23 |
24 | - (void)didReceiveMemoryWarning {
25 | [super didReceiveMemoryWarning];
26 | }
27 |
28 | - (IBAction)showOrHide:(id)sender {
29 | if (self.ccView.isShowing == NO) {
30 | [self.ccView startLodingWormHUD];
31 | }else{
32 | [self.ccView endLodingWormHUD];
33 | }
34 | }
35 |
36 | @end
37 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2016 cocos543
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/Source/CCWormHUD/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 | UIInterfaceOrientationLandscapeLeft
37 | UIInterfaceOrientationLandscapeRight
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/CCWormHUDDemo/CCWormHUDDemo/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 | UIInterfaceOrientationLandscapeLeft
37 | UIInterfaceOrientationLandscapeRight
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/Source/CCWormHUD/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 |
--------------------------------------------------------------------------------
/CCWormHUDDemo/CCWormHUDDemo/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 |
--------------------------------------------------------------------------------
/Source/CCWormHUD/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // CCWormHUD
4 | //
5 | // Created by Cocos on 16/3/17.
6 | // Copyright © 2016年 Cocos. 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 |
--------------------------------------------------------------------------------
/CCWormHUDDemo/CCWormHUDDemo/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // CCWormHUDDemo
4 | //
5 | // Created by 郑克明 on 16/3/21.
6 | // Copyright © 2016年 Cocos. 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 |
--------------------------------------------------------------------------------
/Source/CCWormHUD/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/CCWormHUDDemo/CCWormHUDDemo/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/Source/CCWormHUD.xcodeproj/xcuserdata/Cocos.xcuserdatad/xcschemes/CCWormHUD.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
39 |
40 |
41 |
42 |
43 |
44 |
54 |
56 |
62 |
63 |
64 |
65 |
66 |
67 |
73 |
75 |
81 |
82 |
83 |
84 |
86 |
87 |
90 |
91 |
92 |
--------------------------------------------------------------------------------
/CCWormHUDDemo/CCWormHUDDemo.xcodeproj/xcuserdata/Cocos.xcuserdatad/xcschemes/CCWormHUDDemo.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
39 |
40 |
41 |
42 |
43 |
44 |
54 |
56 |
62 |
63 |
64 |
65 |
66 |
67 |
73 |
75 |
81 |
82 |
83 |
84 |
86 |
87 |
90 |
91 |
92 |
--------------------------------------------------------------------------------
/CCWormHUDDemo/CCWormHUDDemo.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | EDC7EFEB1C9FD17000AB1EF6 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = EDC7EFEA1C9FD17000AB1EF6 /* main.m */; };
11 | EDC7EFEE1C9FD17000AB1EF6 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = EDC7EFED1C9FD17000AB1EF6 /* AppDelegate.m */; };
12 | EDC7EFF11C9FD17000AB1EF6 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = EDC7EFF01C9FD17000AB1EF6 /* ViewController.m */; };
13 | EDC7EFF41C9FD17000AB1EF6 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = EDC7EFF21C9FD17000AB1EF6 /* Main.storyboard */; };
14 | EDC7EFF61C9FD17000AB1EF6 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = EDC7EFF51C9FD17000AB1EF6 /* Assets.xcassets */; };
15 | EDC7EFF91C9FD17000AB1EF6 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = EDC7EFF71C9FD17000AB1EF6 /* LaunchScreen.storyboard */; };
16 | EDC7F0031C9FD1D100AB1EF6 /* CCWormView.m in Sources */ = {isa = PBXBuildFile; fileRef = EDC7F0021C9FD1D100AB1EF6 /* CCWormView.m */; };
17 | /* End PBXBuildFile section */
18 |
19 | /* Begin PBXFileReference section */
20 | EDC7EFE61C9FD17000AB1EF6 /* CCWormHUDDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CCWormHUDDemo.app; sourceTree = BUILT_PRODUCTS_DIR; };
21 | EDC7EFEA1C9FD17000AB1EF6 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; };
22 | EDC7EFEC1C9FD17000AB1EF6 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; };
23 | EDC7EFED1C9FD17000AB1EF6 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; };
24 | EDC7EFEF1C9FD17000AB1EF6 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; };
25 | EDC7EFF01C9FD17000AB1EF6 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; };
26 | EDC7EFF31C9FD17000AB1EF6 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
27 | EDC7EFF51C9FD17000AB1EF6 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
28 | EDC7EFF81C9FD17000AB1EF6 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; };
29 | EDC7EFFA1C9FD17000AB1EF6 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
30 | EDC7F0011C9FD1D100AB1EF6 /* CCWormView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCWormView.h; sourceTree = ""; };
31 | EDC7F0021C9FD1D100AB1EF6 /* CCWormView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CCWormView.m; sourceTree = ""; };
32 | /* End PBXFileReference section */
33 |
34 | /* Begin PBXFrameworksBuildPhase section */
35 | EDC7EFE31C9FD17000AB1EF6 /* Frameworks */ = {
36 | isa = PBXFrameworksBuildPhase;
37 | buildActionMask = 2147483647;
38 | files = (
39 | );
40 | runOnlyForDeploymentPostprocessing = 0;
41 | };
42 | /* End PBXFrameworksBuildPhase section */
43 |
44 | /* Begin PBXGroup section */
45 | EDC7EFDD1C9FD17000AB1EF6 = {
46 | isa = PBXGroup;
47 | children = (
48 | EDC7F0001C9FD1D100AB1EF6 /* ThirdLib */,
49 | EDC7EFE81C9FD17000AB1EF6 /* CCWormHUDDemo */,
50 | EDC7EFE71C9FD17000AB1EF6 /* Products */,
51 | );
52 | sourceTree = "";
53 | };
54 | EDC7EFE71C9FD17000AB1EF6 /* Products */ = {
55 | isa = PBXGroup;
56 | children = (
57 | EDC7EFE61C9FD17000AB1EF6 /* CCWormHUDDemo.app */,
58 | );
59 | name = Products;
60 | sourceTree = "";
61 | };
62 | EDC7EFE81C9FD17000AB1EF6 /* CCWormHUDDemo */ = {
63 | isa = PBXGroup;
64 | children = (
65 | EDC7EFEC1C9FD17000AB1EF6 /* AppDelegate.h */,
66 | EDC7EFED1C9FD17000AB1EF6 /* AppDelegate.m */,
67 | EDC7EFEF1C9FD17000AB1EF6 /* ViewController.h */,
68 | EDC7EFF01C9FD17000AB1EF6 /* ViewController.m */,
69 | EDC7EFF21C9FD17000AB1EF6 /* Main.storyboard */,
70 | EDC7EFF51C9FD17000AB1EF6 /* Assets.xcassets */,
71 | EDC7EFF71C9FD17000AB1EF6 /* LaunchScreen.storyboard */,
72 | EDC7EFFA1C9FD17000AB1EF6 /* Info.plist */,
73 | EDC7EFE91C9FD17000AB1EF6 /* Supporting Files */,
74 | );
75 | path = CCWormHUDDemo;
76 | sourceTree = "";
77 | };
78 | EDC7EFE91C9FD17000AB1EF6 /* Supporting Files */ = {
79 | isa = PBXGroup;
80 | children = (
81 | EDC7EFEA1C9FD17000AB1EF6 /* main.m */,
82 | );
83 | name = "Supporting Files";
84 | sourceTree = "";
85 | };
86 | EDC7F0001C9FD1D100AB1EF6 /* ThirdLib */ = {
87 | isa = PBXGroup;
88 | children = (
89 | EDC7F0011C9FD1D100AB1EF6 /* CCWormView.h */,
90 | EDC7F0021C9FD1D100AB1EF6 /* CCWormView.m */,
91 | );
92 | name = ThirdLib;
93 | path = CCWormHUDDemo/ThirdLib;
94 | sourceTree = "";
95 | };
96 | /* End PBXGroup section */
97 |
98 | /* Begin PBXNativeTarget section */
99 | EDC7EFE51C9FD17000AB1EF6 /* CCWormHUDDemo */ = {
100 | isa = PBXNativeTarget;
101 | buildConfigurationList = EDC7EFFD1C9FD17000AB1EF6 /* Build configuration list for PBXNativeTarget "CCWormHUDDemo" */;
102 | buildPhases = (
103 | EDC7EFE21C9FD17000AB1EF6 /* Sources */,
104 | EDC7EFE31C9FD17000AB1EF6 /* Frameworks */,
105 | EDC7EFE41C9FD17000AB1EF6 /* Resources */,
106 | );
107 | buildRules = (
108 | );
109 | dependencies = (
110 | );
111 | name = CCWormHUDDemo;
112 | productName = CCWormHUDDemo;
113 | productReference = EDC7EFE61C9FD17000AB1EF6 /* CCWormHUDDemo.app */;
114 | productType = "com.apple.product-type.application";
115 | };
116 | /* End PBXNativeTarget section */
117 |
118 | /* Begin PBXProject section */
119 | EDC7EFDE1C9FD17000AB1EF6 /* Project object */ = {
120 | isa = PBXProject;
121 | attributes = {
122 | LastUpgradeCheck = 0720;
123 | ORGANIZATIONNAME = Cocos;
124 | TargetAttributes = {
125 | EDC7EFE51C9FD17000AB1EF6 = {
126 | CreatedOnToolsVersion = 7.2;
127 | DevelopmentTeam = XNC7CRYM5X;
128 | };
129 | };
130 | };
131 | buildConfigurationList = EDC7EFE11C9FD17000AB1EF6 /* Build configuration list for PBXProject "CCWormHUDDemo" */;
132 | compatibilityVersion = "Xcode 3.2";
133 | developmentRegion = English;
134 | hasScannedForEncodings = 0;
135 | knownRegions = (
136 | en,
137 | Base,
138 | );
139 | mainGroup = EDC7EFDD1C9FD17000AB1EF6;
140 | productRefGroup = EDC7EFE71C9FD17000AB1EF6 /* Products */;
141 | projectDirPath = "";
142 | projectRoot = "";
143 | targets = (
144 | EDC7EFE51C9FD17000AB1EF6 /* CCWormHUDDemo */,
145 | );
146 | };
147 | /* End PBXProject section */
148 |
149 | /* Begin PBXResourcesBuildPhase section */
150 | EDC7EFE41C9FD17000AB1EF6 /* Resources */ = {
151 | isa = PBXResourcesBuildPhase;
152 | buildActionMask = 2147483647;
153 | files = (
154 | EDC7EFF91C9FD17000AB1EF6 /* LaunchScreen.storyboard in Resources */,
155 | EDC7EFF61C9FD17000AB1EF6 /* Assets.xcassets in Resources */,
156 | EDC7EFF41C9FD17000AB1EF6 /* Main.storyboard in Resources */,
157 | );
158 | runOnlyForDeploymentPostprocessing = 0;
159 | };
160 | /* End PBXResourcesBuildPhase section */
161 |
162 | /* Begin PBXSourcesBuildPhase section */
163 | EDC7EFE21C9FD17000AB1EF6 /* Sources */ = {
164 | isa = PBXSourcesBuildPhase;
165 | buildActionMask = 2147483647;
166 | files = (
167 | EDC7EFF11C9FD17000AB1EF6 /* ViewController.m in Sources */,
168 | EDC7F0031C9FD1D100AB1EF6 /* CCWormView.m in Sources */,
169 | EDC7EFEE1C9FD17000AB1EF6 /* AppDelegate.m in Sources */,
170 | EDC7EFEB1C9FD17000AB1EF6 /* main.m in Sources */,
171 | );
172 | runOnlyForDeploymentPostprocessing = 0;
173 | };
174 | /* End PBXSourcesBuildPhase section */
175 |
176 | /* Begin PBXVariantGroup section */
177 | EDC7EFF21C9FD17000AB1EF6 /* Main.storyboard */ = {
178 | isa = PBXVariantGroup;
179 | children = (
180 | EDC7EFF31C9FD17000AB1EF6 /* Base */,
181 | );
182 | name = Main.storyboard;
183 | sourceTree = "";
184 | };
185 | EDC7EFF71C9FD17000AB1EF6 /* LaunchScreen.storyboard */ = {
186 | isa = PBXVariantGroup;
187 | children = (
188 | EDC7EFF81C9FD17000AB1EF6 /* Base */,
189 | );
190 | name = LaunchScreen.storyboard;
191 | sourceTree = "";
192 | };
193 | /* End PBXVariantGroup section */
194 |
195 | /* Begin XCBuildConfiguration section */
196 | EDC7EFFB1C9FD17000AB1EF6 /* Debug */ = {
197 | isa = XCBuildConfiguration;
198 | buildSettings = {
199 | ALWAYS_SEARCH_USER_PATHS = NO;
200 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
201 | CLANG_CXX_LIBRARY = "libc++";
202 | CLANG_ENABLE_MODULES = YES;
203 | CLANG_ENABLE_OBJC_ARC = YES;
204 | CLANG_WARN_BOOL_CONVERSION = YES;
205 | CLANG_WARN_CONSTANT_CONVERSION = YES;
206 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
207 | CLANG_WARN_EMPTY_BODY = YES;
208 | CLANG_WARN_ENUM_CONVERSION = YES;
209 | CLANG_WARN_INT_CONVERSION = YES;
210 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
211 | CLANG_WARN_UNREACHABLE_CODE = YES;
212 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
213 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
214 | COPY_PHASE_STRIP = NO;
215 | DEBUG_INFORMATION_FORMAT = dwarf;
216 | ENABLE_STRICT_OBJC_MSGSEND = YES;
217 | ENABLE_TESTABILITY = YES;
218 | GCC_C_LANGUAGE_STANDARD = gnu99;
219 | GCC_DYNAMIC_NO_PIC = NO;
220 | GCC_NO_COMMON_BLOCKS = YES;
221 | GCC_OPTIMIZATION_LEVEL = 0;
222 | GCC_PREPROCESSOR_DEFINITIONS = (
223 | "DEBUG=1",
224 | "$(inherited)",
225 | );
226 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
227 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
228 | GCC_WARN_UNDECLARED_SELECTOR = YES;
229 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
230 | GCC_WARN_UNUSED_FUNCTION = YES;
231 | GCC_WARN_UNUSED_VARIABLE = YES;
232 | IPHONEOS_DEPLOYMENT_TARGET = 8.0;
233 | MTL_ENABLE_DEBUG_INFO = YES;
234 | ONLY_ACTIVE_ARCH = YES;
235 | SDKROOT = iphoneos;
236 | };
237 | name = Debug;
238 | };
239 | EDC7EFFC1C9FD17000AB1EF6 /* Release */ = {
240 | isa = XCBuildConfiguration;
241 | buildSettings = {
242 | ALWAYS_SEARCH_USER_PATHS = NO;
243 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
244 | CLANG_CXX_LIBRARY = "libc++";
245 | CLANG_ENABLE_MODULES = YES;
246 | CLANG_ENABLE_OBJC_ARC = YES;
247 | CLANG_WARN_BOOL_CONVERSION = YES;
248 | CLANG_WARN_CONSTANT_CONVERSION = YES;
249 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
250 | CLANG_WARN_EMPTY_BODY = YES;
251 | CLANG_WARN_ENUM_CONVERSION = YES;
252 | CLANG_WARN_INT_CONVERSION = YES;
253 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
254 | CLANG_WARN_UNREACHABLE_CODE = YES;
255 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
256 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
257 | COPY_PHASE_STRIP = NO;
258 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
259 | ENABLE_NS_ASSERTIONS = NO;
260 | ENABLE_STRICT_OBJC_MSGSEND = YES;
261 | GCC_C_LANGUAGE_STANDARD = gnu99;
262 | GCC_NO_COMMON_BLOCKS = YES;
263 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
264 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
265 | GCC_WARN_UNDECLARED_SELECTOR = YES;
266 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
267 | GCC_WARN_UNUSED_FUNCTION = YES;
268 | GCC_WARN_UNUSED_VARIABLE = YES;
269 | IPHONEOS_DEPLOYMENT_TARGET = 8.0;
270 | MTL_ENABLE_DEBUG_INFO = NO;
271 | SDKROOT = iphoneos;
272 | VALIDATE_PRODUCT = YES;
273 | };
274 | name = Release;
275 | };
276 | EDC7EFFE1C9FD17000AB1EF6 /* Debug */ = {
277 | isa = XCBuildConfiguration;
278 | buildSettings = {
279 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
280 | INFOPLIST_FILE = CCWormHUDDemo/Info.plist;
281 | IPHONEOS_DEPLOYMENT_TARGET = 8.0;
282 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
283 | PRODUCT_BUNDLE_IDENTIFIER = org.cocos.CCWormHUDDemo;
284 | PRODUCT_NAME = "$(TARGET_NAME)";
285 | };
286 | name = Debug;
287 | };
288 | EDC7EFFF1C9FD17000AB1EF6 /* Release */ = {
289 | isa = XCBuildConfiguration;
290 | buildSettings = {
291 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
292 | INFOPLIST_FILE = CCWormHUDDemo/Info.plist;
293 | IPHONEOS_DEPLOYMENT_TARGET = 8.0;
294 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
295 | PRODUCT_BUNDLE_IDENTIFIER = org.cocos.CCWormHUDDemo;
296 | PRODUCT_NAME = "$(TARGET_NAME)";
297 | };
298 | name = Release;
299 | };
300 | /* End XCBuildConfiguration section */
301 |
302 | /* Begin XCConfigurationList section */
303 | EDC7EFE11C9FD17000AB1EF6 /* Build configuration list for PBXProject "CCWormHUDDemo" */ = {
304 | isa = XCConfigurationList;
305 | buildConfigurations = (
306 | EDC7EFFB1C9FD17000AB1EF6 /* Debug */,
307 | EDC7EFFC1C9FD17000AB1EF6 /* Release */,
308 | );
309 | defaultConfigurationIsVisible = 0;
310 | defaultConfigurationName = Release;
311 | };
312 | EDC7EFFD1C9FD17000AB1EF6 /* Build configuration list for PBXNativeTarget "CCWormHUDDemo" */ = {
313 | isa = XCConfigurationList;
314 | buildConfigurations = (
315 | EDC7EFFE1C9FD17000AB1EF6 /* Debug */,
316 | EDC7EFFF1C9FD17000AB1EF6 /* Release */,
317 | );
318 | defaultConfigurationIsVisible = 0;
319 | };
320 | /* End XCConfigurationList section */
321 | };
322 | rootObject = EDC7EFDE1C9FD17000AB1EF6 /* Project object */;
323 | }
324 |
--------------------------------------------------------------------------------
/Source/CCWormHUD.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | ED0D1C2F1C9A8A76001B8138 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = ED0D1C2E1C9A8A76001B8138 /* main.m */; };
11 | ED0D1C321C9A8A76001B8138 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = ED0D1C311C9A8A76001B8138 /* AppDelegate.m */; };
12 | ED0D1C351C9A8A76001B8138 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = ED0D1C341C9A8A76001B8138 /* ViewController.m */; };
13 | ED0D1C381C9A8A76001B8138 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = ED0D1C361C9A8A76001B8138 /* Main.storyboard */; };
14 | ED0D1C3A1C9A8A76001B8138 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = ED0D1C391C9A8A76001B8138 /* Assets.xcassets */; };
15 | ED0D1C3D1C9A8A76001B8138 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = ED0D1C3B1C9A8A76001B8138 /* LaunchScreen.storyboard */; };
16 | EDC7F0071C9FD3EE00AB1EF6 /* CCWormView.m in Sources */ = {isa = PBXBuildFile; fileRef = EDC7F0061C9FD3EE00AB1EF6 /* CCWormView.m */; };
17 | /* End PBXBuildFile section */
18 |
19 | /* Begin PBXFileReference section */
20 | ED0D1C2A1C9A8A76001B8138 /* CCWormHUD.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CCWormHUD.app; sourceTree = BUILT_PRODUCTS_DIR; };
21 | ED0D1C2E1C9A8A76001B8138 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; };
22 | ED0D1C301C9A8A76001B8138 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; };
23 | ED0D1C311C9A8A76001B8138 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; };
24 | ED0D1C331C9A8A76001B8138 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; };
25 | ED0D1C341C9A8A76001B8138 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; };
26 | ED0D1C371C9A8A76001B8138 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
27 | ED0D1C391C9A8A76001B8138 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
28 | ED0D1C3C1C9A8A76001B8138 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; };
29 | ED0D1C3E1C9A8A76001B8138 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
30 | EDC7F0051C9FD3EE00AB1EF6 /* CCWormView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCWormView.h; sourceTree = ""; };
31 | EDC7F0061C9FD3EE00AB1EF6 /* CCWormView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CCWormView.m; sourceTree = ""; };
32 | /* End PBXFileReference section */
33 |
34 | /* Begin PBXFrameworksBuildPhase section */
35 | ED0D1C271C9A8A76001B8138 /* Frameworks */ = {
36 | isa = PBXFrameworksBuildPhase;
37 | buildActionMask = 2147483647;
38 | files = (
39 | );
40 | runOnlyForDeploymentPostprocessing = 0;
41 | };
42 | /* End PBXFrameworksBuildPhase section */
43 |
44 | /* Begin PBXGroup section */
45 | ED0D1C211C9A8A76001B8138 = {
46 | isa = PBXGroup;
47 | children = (
48 | EDC7F0041C9FD3EE00AB1EF6 /* Classes */,
49 | ED0D1C2C1C9A8A76001B8138 /* CCWormHUD */,
50 | ED0D1C2B1C9A8A76001B8138 /* Products */,
51 | );
52 | sourceTree = "";
53 | };
54 | ED0D1C2B1C9A8A76001B8138 /* Products */ = {
55 | isa = PBXGroup;
56 | children = (
57 | ED0D1C2A1C9A8A76001B8138 /* CCWormHUD.app */,
58 | );
59 | name = Products;
60 | sourceTree = "";
61 | };
62 | ED0D1C2C1C9A8A76001B8138 /* CCWormHUD */ = {
63 | isa = PBXGroup;
64 | children = (
65 | ED0D1C301C9A8A76001B8138 /* AppDelegate.h */,
66 | ED0D1C311C9A8A76001B8138 /* AppDelegate.m */,
67 | ED0D1C331C9A8A76001B8138 /* ViewController.h */,
68 | ED0D1C341C9A8A76001B8138 /* ViewController.m */,
69 | ED0D1C361C9A8A76001B8138 /* Main.storyboard */,
70 | ED0D1C391C9A8A76001B8138 /* Assets.xcassets */,
71 | ED0D1C3B1C9A8A76001B8138 /* LaunchScreen.storyboard */,
72 | ED0D1C3E1C9A8A76001B8138 /* Info.plist */,
73 | ED0D1C2D1C9A8A76001B8138 /* Supporting Files */,
74 | );
75 | path = CCWormHUD;
76 | sourceTree = "";
77 | };
78 | ED0D1C2D1C9A8A76001B8138 /* Supporting Files */ = {
79 | isa = PBXGroup;
80 | children = (
81 | ED0D1C2E1C9A8A76001B8138 /* main.m */,
82 | );
83 | name = "Supporting Files";
84 | sourceTree = "";
85 | };
86 | EDC7F0041C9FD3EE00AB1EF6 /* Classes */ = {
87 | isa = PBXGroup;
88 | children = (
89 | EDC7F0051C9FD3EE00AB1EF6 /* CCWormView.h */,
90 | EDC7F0061C9FD3EE00AB1EF6 /* CCWormView.m */,
91 | );
92 | name = Classes;
93 | path = CCWormHUD/Classes;
94 | sourceTree = "";
95 | };
96 | /* End PBXGroup section */
97 |
98 | /* Begin PBXNativeTarget section */
99 | ED0D1C291C9A8A76001B8138 /* CCWormHUD */ = {
100 | isa = PBXNativeTarget;
101 | buildConfigurationList = ED0D1C411C9A8A76001B8138 /* Build configuration list for PBXNativeTarget "CCWormHUD" */;
102 | buildPhases = (
103 | ED0D1C261C9A8A76001B8138 /* Sources */,
104 | ED0D1C271C9A8A76001B8138 /* Frameworks */,
105 | ED0D1C281C9A8A76001B8138 /* Resources */,
106 | );
107 | buildRules = (
108 | );
109 | dependencies = (
110 | );
111 | name = CCWormHUD;
112 | productName = CCWormHUD;
113 | productReference = ED0D1C2A1C9A8A76001B8138 /* CCWormHUD.app */;
114 | productType = "com.apple.product-type.application";
115 | };
116 | /* End PBXNativeTarget section */
117 |
118 | /* Begin PBXProject section */
119 | ED0D1C221C9A8A76001B8138 /* Project object */ = {
120 | isa = PBXProject;
121 | attributes = {
122 | LastUpgradeCheck = 0720;
123 | ORGANIZATIONNAME = "郑克明";
124 | TargetAttributes = {
125 | ED0D1C291C9A8A76001B8138 = {
126 | CreatedOnToolsVersion = 7.2;
127 | };
128 | };
129 | };
130 | buildConfigurationList = ED0D1C251C9A8A76001B8138 /* Build configuration list for PBXProject "CCWormHUD" */;
131 | compatibilityVersion = "Xcode 3.2";
132 | developmentRegion = English;
133 | hasScannedForEncodings = 0;
134 | knownRegions = (
135 | en,
136 | Base,
137 | );
138 | mainGroup = ED0D1C211C9A8A76001B8138;
139 | productRefGroup = ED0D1C2B1C9A8A76001B8138 /* Products */;
140 | projectDirPath = "";
141 | projectRoot = "";
142 | targets = (
143 | ED0D1C291C9A8A76001B8138 /* CCWormHUD */,
144 | );
145 | };
146 | /* End PBXProject section */
147 |
148 | /* Begin PBXResourcesBuildPhase section */
149 | ED0D1C281C9A8A76001B8138 /* Resources */ = {
150 | isa = PBXResourcesBuildPhase;
151 | buildActionMask = 2147483647;
152 | files = (
153 | ED0D1C3D1C9A8A76001B8138 /* LaunchScreen.storyboard in Resources */,
154 | ED0D1C3A1C9A8A76001B8138 /* Assets.xcassets in Resources */,
155 | ED0D1C381C9A8A76001B8138 /* Main.storyboard in Resources */,
156 | );
157 | runOnlyForDeploymentPostprocessing = 0;
158 | };
159 | /* End PBXResourcesBuildPhase section */
160 |
161 | /* Begin PBXSourcesBuildPhase section */
162 | ED0D1C261C9A8A76001B8138 /* Sources */ = {
163 | isa = PBXSourcesBuildPhase;
164 | buildActionMask = 2147483647;
165 | files = (
166 | ED0D1C351C9A8A76001B8138 /* ViewController.m in Sources */,
167 | ED0D1C321C9A8A76001B8138 /* AppDelegate.m in Sources */,
168 | EDC7F0071C9FD3EE00AB1EF6 /* CCWormView.m in Sources */,
169 | ED0D1C2F1C9A8A76001B8138 /* main.m in Sources */,
170 | );
171 | runOnlyForDeploymentPostprocessing = 0;
172 | };
173 | /* End PBXSourcesBuildPhase section */
174 |
175 | /* Begin PBXVariantGroup section */
176 | ED0D1C361C9A8A76001B8138 /* Main.storyboard */ = {
177 | isa = PBXVariantGroup;
178 | children = (
179 | ED0D1C371C9A8A76001B8138 /* Base */,
180 | );
181 | name = Main.storyboard;
182 | sourceTree = "";
183 | };
184 | ED0D1C3B1C9A8A76001B8138 /* LaunchScreen.storyboard */ = {
185 | isa = PBXVariantGroup;
186 | children = (
187 | ED0D1C3C1C9A8A76001B8138 /* Base */,
188 | );
189 | name = LaunchScreen.storyboard;
190 | sourceTree = "";
191 | };
192 | /* End PBXVariantGroup section */
193 |
194 | /* Begin XCBuildConfiguration section */
195 | ED0D1C3F1C9A8A76001B8138 /* Debug */ = {
196 | isa = XCBuildConfiguration;
197 | buildSettings = {
198 | ALWAYS_SEARCH_USER_PATHS = NO;
199 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
200 | CLANG_CXX_LIBRARY = "libc++";
201 | CLANG_ENABLE_MODULES = YES;
202 | CLANG_ENABLE_OBJC_ARC = YES;
203 | CLANG_WARN_BOOL_CONVERSION = YES;
204 | CLANG_WARN_CONSTANT_CONVERSION = YES;
205 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
206 | CLANG_WARN_EMPTY_BODY = YES;
207 | CLANG_WARN_ENUM_CONVERSION = YES;
208 | CLANG_WARN_INT_CONVERSION = YES;
209 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
210 | CLANG_WARN_UNREACHABLE_CODE = YES;
211 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
212 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
213 | COPY_PHASE_STRIP = NO;
214 | DEBUG_INFORMATION_FORMAT = dwarf;
215 | ENABLE_STRICT_OBJC_MSGSEND = YES;
216 | ENABLE_TESTABILITY = YES;
217 | GCC_C_LANGUAGE_STANDARD = gnu99;
218 | GCC_DYNAMIC_NO_PIC = NO;
219 | GCC_NO_COMMON_BLOCKS = YES;
220 | GCC_OPTIMIZATION_LEVEL = 0;
221 | GCC_PREPROCESSOR_DEFINITIONS = (
222 | "DEBUG=1",
223 | "$(inherited)",
224 | );
225 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
226 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
227 | GCC_WARN_UNDECLARED_SELECTOR = YES;
228 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
229 | GCC_WARN_UNUSED_FUNCTION = YES;
230 | GCC_WARN_UNUSED_VARIABLE = YES;
231 | IPHONEOS_DEPLOYMENT_TARGET = 8.4;
232 | MTL_ENABLE_DEBUG_INFO = YES;
233 | ONLY_ACTIVE_ARCH = YES;
234 | SDKROOT = iphoneos;
235 | };
236 | name = Debug;
237 | };
238 | ED0D1C401C9A8A76001B8138 /* Release */ = {
239 | isa = XCBuildConfiguration;
240 | buildSettings = {
241 | ALWAYS_SEARCH_USER_PATHS = NO;
242 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
243 | CLANG_CXX_LIBRARY = "libc++";
244 | CLANG_ENABLE_MODULES = YES;
245 | CLANG_ENABLE_OBJC_ARC = YES;
246 | CLANG_WARN_BOOL_CONVERSION = YES;
247 | CLANG_WARN_CONSTANT_CONVERSION = YES;
248 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
249 | CLANG_WARN_EMPTY_BODY = YES;
250 | CLANG_WARN_ENUM_CONVERSION = YES;
251 | CLANG_WARN_INT_CONVERSION = YES;
252 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
253 | CLANG_WARN_UNREACHABLE_CODE = YES;
254 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
255 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
256 | COPY_PHASE_STRIP = NO;
257 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
258 | ENABLE_NS_ASSERTIONS = NO;
259 | ENABLE_STRICT_OBJC_MSGSEND = YES;
260 | GCC_C_LANGUAGE_STANDARD = gnu99;
261 | GCC_NO_COMMON_BLOCKS = YES;
262 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
263 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
264 | GCC_WARN_UNDECLARED_SELECTOR = YES;
265 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
266 | GCC_WARN_UNUSED_FUNCTION = YES;
267 | GCC_WARN_UNUSED_VARIABLE = YES;
268 | IPHONEOS_DEPLOYMENT_TARGET = 8.4;
269 | MTL_ENABLE_DEBUG_INFO = NO;
270 | SDKROOT = iphoneos;
271 | VALIDATE_PRODUCT = YES;
272 | };
273 | name = Release;
274 | };
275 | ED0D1C421C9A8A76001B8138 /* Debug */ = {
276 | isa = XCBuildConfiguration;
277 | buildSettings = {
278 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
279 | CODE_SIGN_IDENTITY = "iPhone Developer";
280 | INFOPLIST_FILE = CCWormHUD/Info.plist;
281 | IPHONEOS_DEPLOYMENT_TARGET = 8.4;
282 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
283 | PRODUCT_BUNDLE_IDENTIFIER = org.cocos.CCWormHUD;
284 | PRODUCT_NAME = "$(TARGET_NAME)";
285 | };
286 | name = Debug;
287 | };
288 | ED0D1C431C9A8A76001B8138 /* Release */ = {
289 | isa = XCBuildConfiguration;
290 | buildSettings = {
291 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
292 | CODE_SIGN_IDENTITY = "iPhone Developer";
293 | INFOPLIST_FILE = CCWormHUD/Info.plist;
294 | IPHONEOS_DEPLOYMENT_TARGET = 8.4;
295 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
296 | PRODUCT_BUNDLE_IDENTIFIER = org.cocos.CCWormHUD;
297 | PRODUCT_NAME = "$(TARGET_NAME)";
298 | };
299 | name = Release;
300 | };
301 | /* End XCBuildConfiguration section */
302 |
303 | /* Begin XCConfigurationList section */
304 | ED0D1C251C9A8A76001B8138 /* Build configuration list for PBXProject "CCWormHUD" */ = {
305 | isa = XCConfigurationList;
306 | buildConfigurations = (
307 | ED0D1C3F1C9A8A76001B8138 /* Debug */,
308 | ED0D1C401C9A8A76001B8138 /* Release */,
309 | );
310 | defaultConfigurationIsVisible = 0;
311 | defaultConfigurationName = Release;
312 | };
313 | ED0D1C411C9A8A76001B8138 /* Build configuration list for PBXNativeTarget "CCWormHUD" */ = {
314 | isa = XCConfigurationList;
315 | buildConfigurations = (
316 | ED0D1C421C9A8A76001B8138 /* Debug */,
317 | ED0D1C431C9A8A76001B8138 /* Release */,
318 | );
319 | defaultConfigurationIsVisible = 0;
320 | defaultConfigurationName = Release;
321 | };
322 | /* End XCConfigurationList section */
323 | };
324 | rootObject = ED0D1C221C9A8A76001B8138 /* Project object */;
325 | }
326 |
--------------------------------------------------------------------------------
/Source/CCWormHUD/Classes/CCWormView.m:
--------------------------------------------------------------------------------
1 | //
2 | // CCWormView.m
3 | // CCWormHUD
4 | //
5 | // Created by Cocos on 16/3/17.
6 | // Copyright © 2016年 Cocos. All rights reserved.
7 | //
8 |
9 | #import "CCWormView.h"
10 |
11 | //动画半径为HUD尺寸的一半
12 | #define HUDWith 40
13 | #define HUDHeight 40
14 |
15 | #define HUDWithLarge 80
16 | #define HUDHeightLarge 80
17 |
18 | #define LineWidth 6.0f
19 | #define LineWidthLarge 8.0f
20 | #define WormRunTime 1.2f
21 |
22 | #define WORM_ANIMATION_KEY_FIRST @"WORM_ANIMATION_KEY_FIRST"
23 | #define WORM_ANIMATION_KEY_SECOND @"WORM_ANIMATION_KEY_SECOND"
24 | #define WORM_ANIMATION_KEY_THIRD @"WORM_ANIMATION_KEY_THIRD"
25 |
26 |
27 | static NSInteger CCWormHUDViewWith = 0;
28 | static NSInteger CCWormHUDViewHeight = 0;
29 | static NSInteger CCWormHUDLineWidth = 0;
30 | @interface CCWormView ()
31 | @property (nonatomic,strong) CAShapeLayer *firstWormShapeLayer;
32 | @property (nonatomic,strong) CAShapeLayer *secondWormShapeLayer;
33 | @property (nonatomic,strong) CAShapeLayer *thirdWormShapeLayer;
34 |
35 | @property (nonatomic) CCWormHUDStyle hudStyle;
36 | /**
37 | * 用于显示HUD的视图
38 | */
39 | @property (nonatomic,weak) UIView *presentingView;
40 |
41 | @end
42 | @implementation CCWormView
43 |
44 | #pragma mark - 指示器操作
45 |
46 | +(instancetype)wormHUDWithStyle:(CCWormHUDStyle)style toView:(UIView *)toView{
47 |
48 | CCWormView *view;
49 | if (style == CCWormHUDStyleNormal) {
50 | CCWormHUDViewWith = HUDWith;
51 | CCWormHUDViewHeight = HUDHeight;
52 | CCWormHUDLineWidth = LineWidth;
53 | }else if (style == CCWormHUDStyleLarge){
54 | CCWormHUDViewWith = HUDWithLarge;
55 | CCWormHUDViewHeight = HUDHeightLarge;
56 | CCWormHUDLineWidth = LineWidthLarge;
57 | }
58 |
59 | CGRect frame = CGRectZero;
60 | frame.origin.x = toView.frame.origin.x + ( toView.frame.size.width / 2 - CCWormHUDViewWith / 2);
61 | frame.origin.y = toView.frame.origin.y + (toView.frame.size.height / 2 - CCWormHUDViewHeight / 2);
62 | frame.size.width = CCWormHUDViewWith;
63 | frame.size.height = CCWormHUDViewHeight;
64 |
65 | view = [[CCWormView alloc] initWithFrame:frame HUDStyle:style];
66 | view.presentingView = toView;
67 | view.layer.cornerRadius = M_PI * 4;
68 | view.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:.8];
69 | return view;
70 | }
71 |
72 | -(void)startLodingWormHUD{
73 | self.isShowing = YES;
74 | [self.presentingView addSubview:self];
75 | //动起来
76 | [self firstWormAnimation];
77 | [self secondWormAnimation];
78 | [self thirdWormAnimation];
79 |
80 | self.transform = CGAffineTransformMakeScale(0.1, 0.1);
81 | [UIView animateKeyframesWithDuration:0.6 delay:0.0 options:0 animations:^{
82 | [UIView addKeyframeWithRelativeStartTime:0 relativeDuration:0.5 animations:^{
83 | self.transform = CGAffineTransformMakeScale(1.3, 1.3);
84 | }];
85 | [UIView addKeyframeWithRelativeStartTime:0.5 relativeDuration:0.5 animations:^{
86 | self.transform = CGAffineTransformIdentity;
87 | }];
88 | } completion: nil];
89 | }
90 |
91 | -(void)endLodingWormHUD{
92 | //隐藏指示器,同时移除动画
93 | [UIView animateKeyframesWithDuration:0.6 delay:0 options:0 animations:^{
94 | [UIView addKeyframeWithRelativeStartTime:0 relativeDuration:0.5 animations:^{
95 | self.transform = CGAffineTransformMakeScale(1.2, 1.2);
96 | }];
97 | [UIView addKeyframeWithRelativeStartTime:0.5 relativeDuration:0.5 animations:^{
98 | self.transform = CGAffineTransformMakeScale(0.1, 0.1);
99 | }];
100 |
101 | } completion:^(BOOL finished){
102 | self.isShowing = NO;
103 | [self.firstWormShapeLayer removeAnimationForKey:WORM_ANIMATION_KEY_FIRST];
104 | [self.secondWormShapeLayer removeAnimationForKey:WORM_ANIMATION_KEY_SECOND];
105 | [self.thirdWormShapeLayer removeAnimationForKey:WORM_ANIMATION_KEY_THIRD];
106 | [self removeFromSuperview];
107 | }];
108 | }
109 |
110 | #pragma mark - 初始化
111 | -(instancetype)initWithFrame:(CGRect)frame HUDStyle:(CCWormHUDStyle)style{
112 | self = [super initWithFrame:frame];
113 | if (!self){
114 | return nil;
115 | }
116 | self.hudStyle = style;
117 |
118 | CAShapeLayer *firstWormShapeLayer = [[CAShapeLayer alloc] init];
119 | firstWormShapeLayer.path = [self wormRunLongPath];
120 | firstWormShapeLayer.lineWidth = CCWormHUDLineWidth;
121 | firstWormShapeLayer.lineCap = kCALineCapRound;
122 | firstWormShapeLayer.lineJoin = kCALineCapRound;
123 | firstWormShapeLayer.strokeColor = [UIColor redColor].CGColor;
124 | firstWormShapeLayer.fillColor = [UIColor clearColor].CGColor;
125 | firstWormShapeLayer.actions = [[NSDictionary alloc] initWithObjectsAndKeys:[NSNull null],@"strokeStart",[NSNull null],@"strokeEnd", nil];
126 |
127 | CAShapeLayer *secondWormShapeLayer = [[CAShapeLayer alloc] init];
128 | secondWormShapeLayer.path = [self wormRunLongPath];
129 | secondWormShapeLayer.lineWidth = CCWormHUDLineWidth;
130 | secondWormShapeLayer.lineCap = kCALineCapRound;
131 | secondWormShapeLayer.lineJoin = kCALineCapRound;
132 | secondWormShapeLayer.strokeColor = [UIColor yellowColor].CGColor;
133 | secondWormShapeLayer.fillColor = [UIColor clearColor].CGColor;
134 | secondWormShapeLayer.actions = [[NSDictionary alloc] initWithObjectsAndKeys:[NSNull null],@"strokeStart",[NSNull null],@"strokeEnd", nil];
135 |
136 | CAShapeLayer *thirdWormShapeLayer = [[CAShapeLayer alloc] init];
137 | thirdWormShapeLayer.path = [self wormRunLongPath];
138 | thirdWormShapeLayer.lineWidth = CCWormHUDLineWidth;
139 | thirdWormShapeLayer.lineCap = kCALineCapRound;
140 | thirdWormShapeLayer.lineJoin = kCALineCapRound;
141 | thirdWormShapeLayer.strokeColor = [UIColor greenColor].CGColor;
142 | thirdWormShapeLayer.fillColor = [UIColor clearColor].CGColor;
143 | thirdWormShapeLayer.actions = [[NSDictionary alloc] initWithObjectsAndKeys:[NSNull null],@"strokeStart",[NSNull null],@"strokeEnd", nil];
144 |
145 | [self.layer addSublayer:firstWormShapeLayer];
146 | [self.layer addSublayer:secondWormShapeLayer];
147 | [self.layer addSublayer:thirdWormShapeLayer];
148 | self.firstWormShapeLayer = firstWormShapeLayer;
149 | self.secondWormShapeLayer = secondWormShapeLayer;
150 | self.thirdWormShapeLayer = thirdWormShapeLayer;
151 |
152 | return self;
153 | }
154 |
155 | -(CGPathRef)wormRunLongPath{
156 | //确定路径起点位置
157 | CGPoint center;
158 | if (self.hudStyle == CCWormHUDStyleLarge || self.hudStyle==CCWormHUDStyleNormal) {
159 | center = CGPointMake(self.frame.size.width * 9 / 10, self.frame.size.height / 2);
160 | }
161 |
162 | //两个连着的半圆
163 | CGFloat radius = (CCWormHUDViewWith / 2.0) / 2.0;
164 | UIBezierPath *wormPath = [UIBezierPath bezierPathWithArcCenter:center radius:radius startAngle:M_PI endAngle:2 * M_PI clockwise:YES];
165 | [wormPath addArcWithCenter:CGPointMake(center.x + radius * 2, center.y) radius:radius startAngle:M_PI endAngle:2 * M_PI clockwise:YES];
166 |
167 | CGPathRef path = wormPath.CGPath;
168 | return path;
169 |
170 | }
171 |
172 | -(CGPathRef)wormRunLongPathWithStartCut:(CGFloat)startCut endCut:(CGFloat)endCut{
173 | //确定路径起点位置
174 | CGPoint center;
175 | if (self.hudStyle == CCWormHUDStyleLarge || self.hudStyle==CCWormHUDStyleNormal) {
176 | center = CGPointMake(self.frame.size.width * 9 / 10, self.frame.size.height / 2);
177 | }
178 |
179 | //两个连着的半圆
180 | CGFloat radius = (CCWormHUDViewWith / 2.0) / 2.0;
181 | UIBezierPath *wormPath = [UIBezierPath bezierPathWithArcCenter:center radius:radius startAngle:M_PI + startCut endAngle:2 * M_PI clockwise:YES];
182 | [wormPath addArcWithCenter:CGPointMake(center.x + radius * 2, center.y) radius:radius startAngle:M_PI endAngle:2 * M_PI - endCut clockwise:YES];
183 |
184 | CGPathRef path = wormPath.CGPath;
185 | return path;
186 | }
187 |
188 | /**
189 | * 第三条虫子嚅动
190 | */
191 | -(void)thirdWormAnimation{
192 |
193 | CAAnimationGroup *animationGroup = [self baseWormAnimationWithEnd1From:0.010 end1To:0.5 end1Duration:0.75 start1From:0 start1To:0.490 start1Duration:0.9 start1Begin:0.25 end2From:0.5 end2To:0.5 + 0.5 end2Duration:0.75 end2Begin:WormRunTime + 0.15 + 0.20 start2From:0.5 start2To:0.5 + 0.5 start2Duration:0.30 start2Begin:0.15 + 0.75 + WormRunTime];
194 |
195 | [self.thirdWormShapeLayer addAnimation:animationGroup forKey:WORM_ANIMATION_KEY_THIRD];
196 | }
197 |
198 | /**
199 | * 第二条虫子嚅动
200 | */
201 | -(void)secondWormAnimation{
202 |
203 | CAAnimationGroup *animationGroup = [self baseWormAnimationWithEnd1From:0.010 end1To:0.5 end1Duration:0.75 start1From:0 start1To:0.490 start1Duration:0.70 start1Begin:0.50 end2From:0.5 end2To:0.5 + 0.5 end2Duration:0.75 end2Begin:WormRunTime + 0.15 start2From:0.5 start2To:0.5 + 0.5 start2Duration:0.30 start2Begin:0.15 + 0.75 + WormRunTime];
204 |
205 | [self.secondWormShapeLayer addAnimation:animationGroup forKey:WORM_ANIMATION_KEY_SECOND];
206 | }
207 |
208 | /**
209 | * 第一条虫子嚅动 (最底部的那条)
210 | */
211 | -(void)firstWormAnimation{
212 | CAAnimationGroup *animationGroup = [self baseWormAnimationWithEnd1From:0 end1To:0.5 end1Duration:0.75 start1From:0 start1To:0.5 start1Duration:0.45 start1Begin:0.75 end2From:0.5 end2To:0.5 + 0.5 end2Duration:0.75 end2Begin:1.2 start2From:0.5 start2To:0.5 + 0.5 start2Duration:0.45 start2Begin:0.75 + WormRunTime];
213 |
214 | [self.firstWormShapeLayer addAnimation:animationGroup forKey:WORM_ANIMATION_KEY_FIRST];
215 | }
216 |
217 | -(CAAnimationGroup *)baseWormAnimationWithEnd1From:(CGFloat)end1FromValue end1To:(CGFloat)end1ToValue end1Duration:(CGFloat)end1Duration start1From:(CGFloat)start1FromValue start1To:(CGFloat)start1ToValue start1Duration:(CGFloat)start1Duration start1Begin:(CGFloat)start1BeginTime end2From:(CGFloat)end2FromValue end2To:(CGFloat)end2ToValue end2Duration:(CGFloat)end2Duration end2Begin:(CGFloat)end2BeginTime start2From:(CGFloat)start2FromValue start2To:(CGFloat)start2ToValue start2Duration:(CGFloat)start2Duration start2Begin:(CGFloat)start2BeginTime{
218 |
219 |
220 | //虫子拉伸1
221 | CABasicAnimation *strokeEndAm = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
222 | strokeEndAm.toValue = [NSNumber numberWithFloat:end1ToValue];
223 | //fromValue 开始画时已经存在的部分的量
224 | strokeEndAm.fromValue = [NSNumber numberWithFloat:end1FromValue];
225 | strokeEndAm.duration = end1Duration;
226 | strokeEndAm.timingFunction = [CAMediaTimingFunction functionWithControlPoints:0.42 :0.0 :1.0 :0.55];
227 | strokeEndAm.fillMode = kCAFillModeForwards;
228 |
229 | //虫子缩小1
230 | CABasicAnimation *strokeStartAm = [CABasicAnimation animationWithKeyPath:@"strokeStart"];
231 | strokeStartAm.toValue = [NSNumber numberWithFloat:start1ToValue];
232 | strokeStartAm.fromValue = [NSNumber numberWithFloat:start1FromValue];
233 | strokeStartAm.duration = start1Duration;
234 | //如果不被Group加入的话,CACurrentMediaTime() + 1 才表示延迟1秒.
235 | strokeStartAm.beginTime = start1BeginTime;//延迟执行
236 | strokeStartAm.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
237 | strokeStartAm.fillMode = kCAFillModeForwards;
238 |
239 |
240 | //虫子拉伸2 拉伸的第二阶段,必须让上一层的第二阶段先动
241 | CABasicAnimation *strokeEndAm2 = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
242 | strokeEndAm2.toValue = [NSNumber numberWithFloat:end2ToValue];
243 | //fromValue 开始画时已经存在的部分的量
244 | strokeEndAm2.fromValue = [NSNumber numberWithFloat:end2FromValue];
245 | strokeEndAm2.duration = end2Duration;
246 | strokeEndAm2.beginTime = end2BeginTime;
247 | strokeEndAm2.timingFunction = [CAMediaTimingFunction functionWithControlPoints:0.42 :0.0 :1.0 :0.55];
248 | strokeEndAm2.fillMode = kCAFillModeForwards;
249 |
250 | //虫子缩小2
251 | CABasicAnimation *strokeStartAm2 = [CABasicAnimation animationWithKeyPath:@"strokeStart"];
252 | strokeStartAm2.toValue = [NSNumber numberWithFloat:start2ToValue];
253 | strokeStartAm2.fromValue = [NSNumber numberWithFloat:start2FromValue];
254 | strokeStartAm2.duration = start2Duration;
255 | //如果不被Group加入的话,CACurrentMediaTime() + 1 才表示延迟1秒.
256 | strokeStartAm2.beginTime = start2BeginTime;//延迟一秒执行
257 | strokeStartAm2.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
258 |
259 |
260 | //平移动画
261 | CABasicAnimation *xTranslationAm = [CABasicAnimation animationWithKeyPath:@"transform.translation.x"];
262 | xTranslationAm.toValue = [NSNumber numberWithFloat: ( (CCWormHUDViewWith / 2.0) / -1.0)];
263 | xTranslationAm.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
264 | xTranslationAm.duration = 1.18;
265 | xTranslationAm.fillMode = kCAFillModeForwards;
266 |
267 | CABasicAnimation *xTranslationAm2 = [CABasicAnimation animationWithKeyPath:@"transform.translation.x"];
268 | xTranslationAm2.toValue = [NSNumber numberWithFloat: ( (CCWormHUDViewWith / 2.0) / -1.0) * 2];
269 | xTranslationAm2.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
270 | xTranslationAm2.duration = 1.18;
271 | xTranslationAm2.beginTime = 1.20;
272 | xTranslationAm2.fillMode = kCAFillModeForwards;
273 |
274 |
275 |
276 | CAAnimationGroup *animationGroup = [CAAnimationGroup animation];
277 | animationGroup.animations = [NSArray arrayWithObjects: strokeStartAm, strokeEndAm, xTranslationAm, strokeEndAm2, strokeStartAm2, xTranslationAm2, nil];
278 | animationGroup.repeatCount = HUGE_VALF;
279 | //动画总时间应该以组中动画时间最长为标准
280 | animationGroup.duration = WormRunTime * 2;
281 |
282 | return animationGroup;
283 | }
284 |
285 |
286 |
287 | #pragma mark - 测试用
288 |
289 | -(CGPathRef)testPath{
290 | //画一个半圆
291 | UIBezierPath* wormPath = UIBezierPath.bezierPath;
292 | [wormPath moveToPoint: CGPointMake(5,20)];
293 | [wormPath addLineToPoint:CGPointMake(35, 20)];
294 | CGPathRef path = wormPath.CGPath;
295 | return path;
296 | }
297 |
298 | -(void)testAnimation{
299 | CABasicAnimation *strokeStartAm = [CABasicAnimation animationWithKeyPath:@"strokeStart"];
300 | strokeStartAm.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
301 | strokeStartAm.toValue = [NSNumber numberWithFloat:0.2];
302 | strokeStartAm.fromValue = [NSNumber numberWithFloat:1];
303 | strokeStartAm.duration = 2;
304 | strokeStartAm.repeatCount = 100;
305 |
306 | CABasicAnimation *strokeEndAm = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
307 | strokeEndAm.toValue = [NSNumber numberWithFloat:1];
308 | strokeEndAm.fromValue = [NSNumber numberWithFloat:0];
309 | strokeEndAm.duration = 2;
310 | strokeEndAm.repeatCount = 100;
311 |
312 | [self.firstWormShapeLayer addAnimation:strokeEndAm forKey:nil];
313 | }
314 | @end
315 |
--------------------------------------------------------------------------------
/CCWormHUDDemo/CCWormHUDDemo/ThirdLib/CCWormView.m:
--------------------------------------------------------------------------------
1 | //
2 | // CCWormView.m
3 | // CCWormHUD
4 | //
5 | // Created by 郑克明 on 16/3/17.
6 | // Copyright © 2016年 Cocos. All rights reserved.
7 | //
8 |
9 | /*
10 | CCWormView对每一个父View都提供唯一的HUD,同一个父View多次调用loding将反复出现同一个HUD.
11 | */
12 | #import "CCWormView.h"
13 |
14 | //动画半径为HUD尺寸的一半
15 | #define HUDWith 40
16 | #define HUDHeight 40
17 |
18 | #define HUDWithLarge 80
19 | #define HUDHeightLarge 80
20 |
21 | #define LineWidth 6.0f
22 | #define LineWidthLarge 8.0f
23 | #define WormRunTime 1.2f
24 |
25 | #define WORM_ANIMATION_KEY_FIRST @"WORM_ANIMATION_KEY_FIRST"
26 | #define WORM_ANIMATION_KEY_SECOND @"WORM_ANIMATION_KEY_SECOND"
27 | #define WORM_ANIMATION_KEY_THIRD @"WORM_ANIMATION_KEY_THIRD"
28 |
29 |
30 | static NSInteger CCWormHUDViewWith = 0;
31 | static NSInteger CCWormHUDViewHeight = 0;
32 | static NSInteger CCWormHUDLineWidth = 0;
33 | @interface CCWormView ()
34 | @property (nonatomic,strong) CAShapeLayer *firstWormShapeLayer;
35 | @property (nonatomic,strong) CAShapeLayer *secondWormShapeLayer;
36 | @property (nonatomic,strong) CAShapeLayer *thirdWormShapeLayer;
37 |
38 | @property (nonatomic) CCWormHUDStyle hudStyle;
39 | /**
40 | * 用于显示HUD的视图
41 | */
42 | @property (nonatomic,weak) UIView *presentingView;
43 |
44 | @end
45 | @implementation CCWormView
46 |
47 | #pragma mark - 指示器操作
48 |
49 | +(instancetype)wormHUDWithStyle:(CCWormHUDStyle)style toView:(UIView *)toView{
50 |
51 | CCWormView *view;
52 | if (style == CCWormHUDStyleNormal) {
53 | CCWormHUDViewWith = HUDWith;
54 | CCWormHUDViewHeight = HUDHeight;
55 | CCWormHUDLineWidth = LineWidth;
56 | }else if (style == CCWormHUDStyleLarge){
57 | CCWormHUDViewWith = HUDWithLarge;
58 | CCWormHUDViewHeight = HUDHeightLarge;
59 | CCWormHUDLineWidth = LineWidthLarge;
60 | }
61 |
62 | CGRect frame = CGRectZero;
63 | frame.origin.x = toView.frame.origin.x + ( toView.frame.size.width / 2 - CCWormHUDViewWith / 2);
64 | frame.origin.y = toView.frame.origin.y + (toView.frame.size.height / 2 - CCWormHUDViewHeight / 2);
65 | frame.size.width = CCWormHUDViewWith;
66 | frame.size.height = CCWormHUDViewHeight;
67 |
68 | view = [[CCWormView alloc] initWithFrame:frame HUDStyle:style];
69 | view.presentingView = toView;
70 | view.layer.cornerRadius = M_PI * 4;
71 | view.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:.8];
72 | return view;
73 | }
74 |
75 | -(void)startLodingWormHUD{
76 | self.isShowing = YES;
77 | [self.presentingView addSubview:self];
78 | //动起来
79 | [self firstWormAnimation];
80 | [self secondWormAnimation];
81 | [self thirdWormAnimation];
82 |
83 | self.transform = CGAffineTransformMakeScale(0.1, 0.1);
84 | [UIView animateKeyframesWithDuration:0.6 delay:0.0 options:0 animations:^{
85 | [UIView addKeyframeWithRelativeStartTime:0 relativeDuration:0.5 animations:^{
86 | self.transform = CGAffineTransformMakeScale(1.3, 1.3);
87 | }];
88 | [UIView addKeyframeWithRelativeStartTime:0.5 relativeDuration:0.5 animations:^{
89 | self.transform = CGAffineTransformIdentity;
90 | }];
91 | } completion: nil];
92 | }
93 |
94 | -(void)endLodingWormHUD{
95 | //隐藏指示器,同时移除动画
96 | [UIView animateKeyframesWithDuration:0.6 delay:0 options:0 animations:^{
97 | [UIView addKeyframeWithRelativeStartTime:0 relativeDuration:0.5 animations:^{
98 | self.transform = CGAffineTransformMakeScale(1.2, 1.2);
99 | }];
100 | [UIView addKeyframeWithRelativeStartTime:0.5 relativeDuration:0.5 animations:^{
101 | self.transform = CGAffineTransformMakeScale(0.1, 0.1);
102 | }];
103 |
104 | } completion:^(BOOL finished){
105 | self.isShowing = NO;
106 | [self.firstWormShapeLayer removeAnimationForKey:WORM_ANIMATION_KEY_FIRST];
107 | [self.secondWormShapeLayer removeAnimationForKey:WORM_ANIMATION_KEY_SECOND];
108 | [self.thirdWormShapeLayer removeAnimationForKey:WORM_ANIMATION_KEY_THIRD];
109 | [self removeFromSuperview];
110 | }];
111 | }
112 |
113 | #pragma mark - 初始化
114 | -(instancetype)initWithFrame:(CGRect)frame HUDStyle:(CCWormHUDStyle)style{
115 | self = [super initWithFrame:frame];
116 | if (!self){
117 | return nil;
118 | }
119 | self.hudStyle = style;
120 |
121 | CAShapeLayer *firstWormShapeLayer = [[CAShapeLayer alloc] init];
122 | firstWormShapeLayer.path = [self wormRunLongPath];
123 | firstWormShapeLayer.lineWidth = CCWormHUDLineWidth;
124 | firstWormShapeLayer.lineCap = kCALineCapRound;
125 | firstWormShapeLayer.strokeColor = [UIColor redColor].CGColor;
126 | firstWormShapeLayer.fillColor = [UIColor clearColor].CGColor;
127 | firstWormShapeLayer.actions = [[NSDictionary alloc] initWithObjectsAndKeys:[NSNull null],@"strokeStart",[NSNull null],@"strokeEnd", nil];
128 |
129 | CAShapeLayer *secondWormShapeLayer = [[CAShapeLayer alloc] init];
130 | secondWormShapeLayer.path = [self wormRunLongPath];
131 | secondWormShapeLayer.lineWidth = CCWormHUDLineWidth;
132 | secondWormShapeLayer.lineCap = kCALineCapRound;
133 | secondWormShapeLayer.lineJoin = kCALineCapRound;
134 | secondWormShapeLayer.strokeColor = [UIColor yellowColor].CGColor;
135 | secondWormShapeLayer.fillColor = [UIColor clearColor].CGColor;
136 | secondWormShapeLayer.actions = [[NSDictionary alloc] initWithObjectsAndKeys:[NSNull null],@"strokeStart",[NSNull null],@"strokeEnd", nil];
137 |
138 | CAShapeLayer *thirdWormShapeLayer = [[CAShapeLayer alloc] init];
139 | thirdWormShapeLayer.path = [self wormRunLongPath];
140 | thirdWormShapeLayer.lineWidth = CCWormHUDLineWidth;
141 | thirdWormShapeLayer.lineCap = kCALineCapRound;
142 | thirdWormShapeLayer.lineJoin = kCALineCapRound;
143 | thirdWormShapeLayer.strokeColor = [UIColor greenColor].CGColor;
144 | thirdWormShapeLayer.fillColor = [UIColor clearColor].CGColor;
145 | thirdWormShapeLayer.actions = [[NSDictionary alloc] initWithObjectsAndKeys:[NSNull null],@"strokeStart",[NSNull null],@"strokeEnd", nil];
146 |
147 | [self.layer addSublayer:firstWormShapeLayer];
148 | [self.layer addSublayer:secondWormShapeLayer];
149 | [self.layer addSublayer:thirdWormShapeLayer];
150 | self.firstWormShapeLayer = firstWormShapeLayer;
151 | self.secondWormShapeLayer = secondWormShapeLayer;
152 | self.thirdWormShapeLayer = thirdWormShapeLayer;
153 |
154 | return self;
155 | }
156 |
157 | -(CGPathRef)wormRunLongPath{
158 | //确定路径起点位置
159 | CGPoint center;
160 | if (self.hudStyle == CCWormHUDStyleLarge || self.hudStyle==CCWormHUDStyleNormal) {
161 | center = CGPointMake(self.frame.size.width * 9 / 10, self.frame.size.height / 2);
162 | }
163 |
164 | //两个连着的半圆
165 | CGFloat radius = (CCWormHUDViewWith / 2.0) / 2.0;
166 | UIBezierPath *wormPath = [UIBezierPath bezierPathWithArcCenter:center radius:radius startAngle:M_PI endAngle:2 * M_PI clockwise:YES];
167 | [wormPath addArcWithCenter:CGPointMake(center.x + radius * 2, center.y) radius:radius startAngle:M_PI endAngle:2 * M_PI clockwise:YES];
168 |
169 | CGPathRef path = wormPath.CGPath;
170 | return path;
171 |
172 | }
173 |
174 | -(CGPathRef)wormRunLongPathWithStartCut:(CGFloat)startCut endCut:(CGFloat)endCut{
175 | //确定路径起点位置
176 | CGPoint center;
177 | if (self.hudStyle == CCWormHUDStyleLarge || self.hudStyle==CCWormHUDStyleNormal) {
178 | center = CGPointMake(self.frame.size.width * 9 / 10, self.frame.size.height / 2);
179 | }
180 |
181 | //两个连着的半圆
182 | CGFloat radius = (CCWormHUDViewWith / 2.0) / 2.0;
183 | UIBezierPath *wormPath = [UIBezierPath bezierPathWithArcCenter:center radius:radius startAngle:M_PI + startCut endAngle:2 * M_PI clockwise:YES];
184 | [wormPath addArcWithCenter:CGPointMake(center.x + radius * 2, center.y) radius:radius startAngle:M_PI endAngle:2 * M_PI - endCut clockwise:YES];
185 |
186 | CGPathRef path = wormPath.CGPath;
187 | return path;
188 | }
189 |
190 | /**
191 | * 第三条虫子嚅动
192 | */
193 | -(void)thirdWormAnimation{
194 |
195 | CAAnimationGroup *animationGroup = [self baseWormAnimationWithEnd1From:0.010 end1To:0.5 end1Duration:0.75 start1From:0 start1To:0.490 start1Duration:0.9 start1Begin:0.25 end2From:0.5 end2To:0.5 + 0.5 end2Duration:0.75 end2Begin:WormRunTime + 0.15 + 0.20 start2From:0.5 start2To:0.5 + 0.5 start2Duration:0.30 start2Begin:0.15 + 0.75 + WormRunTime];
196 |
197 | [self.thirdWormShapeLayer addAnimation:animationGroup forKey:WORM_ANIMATION_KEY_THIRD];
198 | }
199 |
200 | /**
201 | * 第二条虫子嚅动
202 | */
203 | -(void)secondWormAnimation{
204 |
205 | CAAnimationGroup *animationGroup = [self baseWormAnimationWithEnd1From:0.010 end1To:0.5 end1Duration:0.75 start1From:0 start1To:0.490 start1Duration:0.70 start1Begin:0.50 end2From:0.5 end2To:0.5 + 0.5 end2Duration:0.75 end2Begin:WormRunTime + 0.15 start2From:0.5 start2To:0.5 + 0.5 start2Duration:0.30 start2Begin:0.15 + 0.75 + WormRunTime];
206 |
207 | [self.secondWormShapeLayer addAnimation:animationGroup forKey:WORM_ANIMATION_KEY_SECOND];
208 | }
209 |
210 | /**
211 | * 第一条虫子嚅动 (最底部的那条)
212 | */
213 | -(void)firstWormAnimation{
214 | CAAnimationGroup *animationGroup = [self baseWormAnimationWithEnd1From:0 end1To:0.5 end1Duration:0.75 start1From:0 start1To:0.5 start1Duration:0.45 start1Begin:0.75 end2From:0.5 end2To:0.5 + 0.5 end2Duration:0.75 end2Begin:1.2 start2From:0.5 start2To:0.5 + 0.5 start2Duration:0.45 start2Begin:0.75 + WormRunTime];
215 |
216 | [self.firstWormShapeLayer addAnimation:animationGroup forKey:WORM_ANIMATION_KEY_FIRST];
217 | }
218 |
219 | -(CAAnimationGroup *)baseWormAnimationWithEnd1From:(CGFloat)end1FromValue end1To:(CGFloat)end1ToValue end1Duration:(CGFloat)end1Duration start1From:(CGFloat)start1FromValue start1To:(CGFloat)start1ToValue start1Duration:(CGFloat)start1Duration start1Begin:(CGFloat)start1BeginTime end2From:(CGFloat)end2FromValue end2To:(CGFloat)end2ToValue end2Duration:(CGFloat)end2Duration end2Begin:(CGFloat)end2BeginTime start2From:(CGFloat)start2FromValue start2To:(CGFloat)start2ToValue start2Duration:(CGFloat)start2Duration start2Begin:(CGFloat)start2BeginTime{
220 |
221 |
222 | //虫子拉伸1
223 | CABasicAnimation *strokeEndAm = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
224 | strokeEndAm.toValue = [NSNumber numberWithFloat:end1ToValue];
225 | //fromValue 开始画时已经存在的部分的量
226 | strokeEndAm.fromValue = [NSNumber numberWithFloat:end1FromValue];
227 | strokeEndAm.duration = end1Duration;
228 | strokeEndAm.timingFunction = [CAMediaTimingFunction functionWithControlPoints:0.42 :0.0 :1.0 :0.55];
229 | strokeEndAm.fillMode = kCAFillModeForwards;
230 |
231 | //虫子缩小1
232 | CABasicAnimation *strokeStartAm = [CABasicAnimation animationWithKeyPath:@"strokeStart"];
233 | strokeStartAm.toValue = [NSNumber numberWithFloat:start1ToValue];
234 | strokeStartAm.fromValue = [NSNumber numberWithFloat:start1FromValue];
235 | strokeStartAm.duration = start1Duration;
236 | //如果不被Group加入的话,CACurrentMediaTime() + 1 才表示延迟1秒.
237 | strokeStartAm.beginTime = start1BeginTime;//延迟执行
238 | strokeStartAm.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
239 | strokeStartAm.fillMode = kCAFillModeForwards;
240 |
241 |
242 | //虫子拉伸2 拉伸的第二阶段,必须让上一层的第二阶段先动
243 | CABasicAnimation *strokeEndAm2 = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
244 | strokeEndAm2.toValue = [NSNumber numberWithFloat:end2ToValue];
245 | //fromValue 开始画时已经存在的部分的量
246 | strokeEndAm2.fromValue = [NSNumber numberWithFloat:end2FromValue];
247 | strokeEndAm2.duration = end2Duration;
248 | strokeEndAm2.beginTime = end2BeginTime;
249 | strokeEndAm2.timingFunction = [CAMediaTimingFunction functionWithControlPoints:0.42 :0.0 :1.0 :0.55];
250 | strokeEndAm2.fillMode = kCAFillModeForwards;
251 |
252 | //虫子缩小2
253 | CABasicAnimation *strokeStartAm2 = [CABasicAnimation animationWithKeyPath:@"strokeStart"];
254 | strokeStartAm2.toValue = [NSNumber numberWithFloat:start2ToValue];
255 | strokeStartAm2.fromValue = [NSNumber numberWithFloat:start2FromValue];
256 | strokeStartAm2.duration = start2Duration;
257 | //如果不被Group加入的话,CACurrentMediaTime() + 1 才表示延迟1秒.
258 | strokeStartAm2.beginTime = start2BeginTime;//延迟一秒执行
259 | strokeStartAm2.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
260 |
261 |
262 | //平移动画
263 | CABasicAnimation *xTranslationAm = [CABasicAnimation animationWithKeyPath:@"transform.translation.x"];
264 | xTranslationAm.toValue = [NSNumber numberWithFloat: ( (CCWormHUDViewWith / 2.0) / -1.0)];
265 | xTranslationAm.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
266 | xTranslationAm.duration = 1.18;
267 | xTranslationAm.fillMode = kCAFillModeForwards;
268 |
269 | CABasicAnimation *xTranslationAm2 = [CABasicAnimation animationWithKeyPath:@"transform.translation.x"];
270 | xTranslationAm2.toValue = [NSNumber numberWithFloat: ( (CCWormHUDViewWith / 2.0) / -1.0) * 2];
271 | xTranslationAm2.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
272 | xTranslationAm2.duration = 1.18;
273 | xTranslationAm2.beginTime = 1.20;
274 | xTranslationAm2.fillMode = kCAFillModeForwards;
275 |
276 |
277 |
278 | CAAnimationGroup *animationGroup = [CAAnimationGroup animation];
279 | animationGroup.animations = [NSArray arrayWithObjects: strokeStartAm, strokeEndAm, xTranslationAm, strokeEndAm2, strokeStartAm2, xTranslationAm2, nil];
280 | animationGroup.repeatCount = HUGE_VALF;
281 | //动画总时间应该以组中动画时间最长为标准
282 | animationGroup.duration = WormRunTime * 2;
283 |
284 | return animationGroup;
285 | }
286 |
287 |
288 |
289 | #pragma mark - 测试用
290 |
291 | -(CGPathRef)testPath{
292 | //画一个半圆
293 | UIBezierPath* wormPath = UIBezierPath.bezierPath;
294 | [wormPath moveToPoint: CGPointMake(5,20)];
295 | [wormPath addLineToPoint:CGPointMake(35, 20)];
296 | CGPathRef path = wormPath.CGPath;
297 | return path;
298 | }
299 |
300 | -(void)testAnimation{
301 | CABasicAnimation *strokeStartAm = [CABasicAnimation animationWithKeyPath:@"strokeStart"];
302 | strokeStartAm.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
303 | strokeStartAm.toValue = [NSNumber numberWithFloat:0.2];
304 | strokeStartAm.fromValue = [NSNumber numberWithFloat:1];
305 | strokeStartAm.duration = 2;
306 | strokeStartAm.repeatCount = 100;
307 |
308 | CABasicAnimation *strokeEndAm = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
309 | strokeEndAm.toValue = [NSNumber numberWithFloat:1];
310 | strokeEndAm.fromValue = [NSNumber numberWithFloat:0];
311 | strokeEndAm.duration = 2;
312 | strokeEndAm.repeatCount = 100;
313 |
314 | [self.firstWormShapeLayer addAnimation:strokeEndAm forKey:nil];
315 | }
316 | @end
317 |
--------------------------------------------------------------------------------