├── CoreHttp.xcodeproj
├── project.pbxproj
├── project.xcworkspace
│ ├── contents.xcworkspacedata
│ ├── xcshareddata
│ │ └── CoreHttp.xccheckout
│ └── xcuserdata
│ │ ├── Charlin.xcuserdatad
│ │ └── UserInterfaceState.xcuserstate
│ │ └── huaxi100.xcuserdatad
│ │ └── UserInterfaceState.xcuserstate
└── xcuserdata
│ ├── Charlin.xcuserdatad
│ ├── xcdebugger
│ │ └── Breakpoints_v2.xcbkptlist
│ └── xcschemes
│ │ ├── CoreHttp.xcscheme
│ │ └── xcschememanagement.plist
│ └── huaxi100.xcuserdatad
│ ├── xcdebugger
│ └── Breakpoints_v2.xcbkptlist
│ └── xcschemes
│ ├── CoreHttp.xcscheme
│ └── xcschememanagement.plist
├── CoreHttp
├── AppDelegate.h
├── AppDelegate.m
├── Base.lproj
│ ├── LaunchScreen.xib
│ └── Main.storyboard
├── CoreHttp
│ ├── CoreHttp.h
│ ├── CoreHttp.m
│ ├── NSString+CoreHttp
│ │ ├── NSString+CoreHttp.h
│ │ └── NSString+CoreHttp.m
│ └── Upload
│ │ ├── NSData+MimeType.h
│ │ ├── NSData+MimeType.m
│ │ ├── NSData+Param.h
│ │ ├── NSData+Param.m
│ │ ├── NSString+File.h
│ │ ├── NSString+File.m
│ │ ├── NSURL+File.h
│ │ ├── NSURL+File.m
│ │ ├── UploadFile.h
│ │ └── UploadFile.m
├── FrameWorks
│ ├── APPHttp
│ │ ├── APPHttp.h
│ │ ├── APPHttp.m
│ │ └── Lib
│ │ │ ├── APPHttpType.h
│ │ │ └── Singleton
│ │ │ └── APPHttpSingleton.h
│ ├── CoreBtn
│ │ ├── Anim
│ │ │ ├── AnimForCoreBtn.h
│ │ │ └── AnimForCoreBtn.m
│ │ ├── CoreBtn.h
│ │ ├── CoreBtn.m
│ │ ├── CoreStatusBtn.h
│ │ ├── CoreStatusBtn.m
│ │ ├── UIImage+ColorForBtn
│ │ │ ├── UIImage+ColorForBtn.h
│ │ │ └── UIImage+ColorForBtn.m
│ │ └── View
│ │ │ ├── CoreStatusBtnMaskView.h
│ │ │ ├── CoreStatusBtnMaskView.m
│ │ │ └── CoreStatusBtnMaskView.xib
│ ├── CoreIV
│ │ ├── CoreIV.h
│ │ ├── CoreIV.m
│ │ ├── CoreIV.xib
│ │ └── Lib
│ │ │ ├── CoreIV.bundle
│ │ │ ├── smile_failed@2x.png
│ │ │ └── smile_failed@3x.png
│ │ │ └── DGActivityIndicatorView
│ │ │ ├── Animations
│ │ │ ├── DGActivityIndicatorBallBeatAnimation.h
│ │ │ ├── DGActivityIndicatorBallBeatAnimation.m
│ │ │ ├── DGActivityIndicatorBallClipRotateAnimation.h
│ │ │ ├── DGActivityIndicatorBallClipRotateAnimation.m
│ │ │ ├── DGActivityIndicatorBallClipRotateMultipleAnimation.h
│ │ │ ├── DGActivityIndicatorBallClipRotateMultipleAnimation.m
│ │ │ ├── DGActivityIndicatorBallClipRotatePulseAnimation.h
│ │ │ ├── DGActivityIndicatorBallClipRotatePulseAnimation.m
│ │ │ ├── DGActivityIndicatorBallGridBeatAnimation.h
│ │ │ ├── DGActivityIndicatorBallGridBeatAnimation.m
│ │ │ ├── DGActivityIndicatorBallGridPulseAnimation.h
│ │ │ ├── DGActivityIndicatorBallGridPulseAnimation.m
│ │ │ ├── DGActivityIndicatorBallPulseAnimation.h
│ │ │ ├── DGActivityIndicatorBallPulseAnimation.m
│ │ │ ├── DGActivityIndicatorBallPulseSyncAnimation.h
│ │ │ ├── DGActivityIndicatorBallPulseSyncAnimation.m
│ │ │ ├── DGActivityIndicatorBallRotateAnimation.h
│ │ │ ├── DGActivityIndicatorBallRotateAnimation.m
│ │ │ ├── DGActivityIndicatorBallScaleAnimation.h
│ │ │ ├── DGActivityIndicatorBallScaleAnimation.m
│ │ │ ├── DGActivityIndicatorBallScaleMultipleAnimation.h
│ │ │ ├── DGActivityIndicatorBallScaleMultipleAnimation.m
│ │ │ ├── DGActivityIndicatorBallScaleRippleAnimation.h
│ │ │ ├── DGActivityIndicatorBallScaleRippleAnimation.m
│ │ │ ├── DGActivityIndicatorBallScaleRippleMultipleAnimation.h
│ │ │ ├── DGActivityIndicatorBallScaleRippleMultipleAnimation.m
│ │ │ ├── DGActivityIndicatorBallSpinFadeLoader.h
│ │ │ ├── DGActivityIndicatorBallSpinFadeLoader.m
│ │ │ ├── DGActivityIndicatorBallTrianglePathAnimation.h
│ │ │ ├── DGActivityIndicatorBallTrianglePathAnimation.m
│ │ │ ├── DGActivityIndicatorBallZigZagAnimation.h
│ │ │ ├── DGActivityIndicatorBallZigZagAnimation.m
│ │ │ ├── DGActivityIndicatorBallZigZagDeflectAnimation.h
│ │ │ ├── DGActivityIndicatorBallZigZagDeflectAnimation.m
│ │ │ ├── DGActivityIndicatorCookieTerminatorAnimation.h
│ │ │ ├── DGActivityIndicatorCookieTerminatorAnimation.m
│ │ │ ├── DGActivityIndicatorDoubleBounceAnimation.h
│ │ │ ├── DGActivityIndicatorDoubleBounceAnimation.m
│ │ │ ├── DGActivityIndicatorFiveDotsAnimation.h
│ │ │ ├── DGActivityIndicatorFiveDotsAnimation.m
│ │ │ ├── DGActivityIndicatorLineScaleAnimation.h
│ │ │ ├── DGActivityIndicatorLineScaleAnimation.m
│ │ │ ├── DGActivityIndicatorLineScalePartyAnimation.h
│ │ │ ├── DGActivityIndicatorLineScalePartyAnimation.m
│ │ │ ├── DGActivityIndicatorLineScalePulseOutAnimation.h
│ │ │ ├── DGActivityIndicatorLineScalePulseOutAnimation.m
│ │ │ ├── DGActivityIndicatorLineScalePulseOutRapidAnimation.h
│ │ │ ├── DGActivityIndicatorLineScalePulseOutRapidAnimation.m
│ │ │ ├── DGActivityIndicatorNineDotsAnimation.h
│ │ │ ├── DGActivityIndicatorNineDotsAnimation.m
│ │ │ ├── DGActivityIndicatorRotatingSandglassAnimation.h
│ │ │ ├── DGActivityIndicatorRotatingSandglassAnimation.m
│ │ │ ├── DGActivityIndicatorRotatingSquaresAnimation.h
│ │ │ ├── DGActivityIndicatorRotatingSquaresAnimation.m
│ │ │ ├── DGActivityIndicatorRotatingTrigonAnimation.h
│ │ │ ├── DGActivityIndicatorRotatingTrigonAnimation.m
│ │ │ ├── DGActivityIndicatorThreeDotsAnimation.h
│ │ │ ├── DGActivityIndicatorThreeDotsAnimation.m
│ │ │ ├── DGActivityIndicatorTriangleSkewSpinAnimation.h
│ │ │ ├── DGActivityIndicatorTriangleSkewSpinAnimation.m
│ │ │ ├── DGActivityIndicatorTriplePulseAnimation.h
│ │ │ ├── DGActivityIndicatorTriplePulseAnimation.m
│ │ │ ├── DGActivityIndicatorTripleRingsAnimation.h
│ │ │ ├── DGActivityIndicatorTripleRingsAnimation.m
│ │ │ ├── DGActivityIndicatorTwoDotsAnimation.h
│ │ │ └── DGActivityIndicatorTwoDotsAnimation.m
│ │ │ ├── DGActivityIndicatorAnimationProtocol.h
│ │ │ ├── DGActivityIndicatorView.h
│ │ │ └── DGActivityIndicatorView.m
│ ├── CoreSVP
│ │ ├── CoreSVP+Swift.swift
│ │ ├── CoreSVP.h
│ │ ├── CoreSVP.m
│ │ └── Lib
│ │ │ ├── SVP.bundle
│ │ │ ├── green@2x.png
│ │ │ ├── green@3x.png
│ │ │ ├── red@2x.png
│ │ │ ├── red@3x.png
│ │ │ └── yellow@2x.png
│ │ │ └── SVProgressHUD
│ │ │ ├── SVIndefiniteAnimatedView.h
│ │ │ ├── SVIndefiniteAnimatedView.m
│ │ │ ├── SVProgressHUD-Prefix.pch
│ │ │ ├── SVProgressHUD.bundle
│ │ │ ├── angle-mask.png
│ │ │ ├── angle-mask@2x.png
│ │ │ ├── angle-mask@3x.png
│ │ │ ├── error.png
│ │ │ ├── error@2x.png
│ │ │ ├── error@3x.png
│ │ │ ├── info.png
│ │ │ ├── info@2x.png
│ │ │ ├── info@3x.png
│ │ │ ├── success.png
│ │ │ ├── success@2x.png
│ │ │ └── success@3x.png
│ │ │ ├── SVProgressHUD.h
│ │ │ └── SVProgressHUD.m
│ └── CoreStatus
│ │ ├── CoreStatus.h
│ │ ├── CoreStatus.m
│ │ └── Lib
│ │ ├── CoreNetworkStatus.h
│ │ ├── CoreStatusProtocol.h
│ │ ├── Reachability
│ │ ├── Reachability.h
│ │ └── Reachability.m
│ │ └── Singleton
│ │ └── CoreStatusSingleton.h
├── Images.xcassets
│ ├── AppIcon.appiconset
│ │ └── Contents.json
│ └── LaunchImage.launchimage
│ │ └── Contents.json
├── Info.plist
├── ViewController.h
├── ViewController.m
├── charlin.jpg
├── cut.png
└── main.m
├── CoreHttpTests
├── CoreHttpTests.m
└── Info.plist
└── README.md
/CoreHttp.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/CoreHttp.xcodeproj/project.xcworkspace/xcshareddata/CoreHttp.xccheckout:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDESourceControlProjectFavoriteDictionaryKey
6 |
7 | IDESourceControlProjectIdentifier
8 | B4380082-69AE-422A-8259-B1DEE778A0B2
9 | IDESourceControlProjectName
10 | CoreHttp
11 | IDESourceControlProjectOriginsDictionary
12 |
13 | 929CED7358B39DE998D4C5B9E17F602B3A362272
14 | https://github.com/nsdictionary/CoreHttp.git
15 |
16 | IDESourceControlProjectPath
17 | CoreHttp.xcodeproj
18 | IDESourceControlProjectRelativeInstallPathDictionary
19 |
20 | 929CED7358B39DE998D4C5B9E17F602B3A362272
21 | ../..
22 |
23 | IDESourceControlProjectURL
24 | https://github.com/nsdictionary/CoreHttp.git
25 | IDESourceControlProjectVersion
26 | 111
27 | IDESourceControlProjectWCCIdentifier
28 | 929CED7358B39DE998D4C5B9E17F602B3A362272
29 | IDESourceControlProjectWCConfigurations
30 |
31 |
32 | IDESourceControlRepositoryExtensionIdentifierKey
33 | public.vcs.git
34 | IDESourceControlWCCIdentifierKey
35 | 929CED7358B39DE998D4C5B9E17F602B3A362272
36 | IDESourceControlWCCName
37 | CoreHttp
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/CoreHttp.xcodeproj/project.xcworkspace/xcuserdata/Charlin.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CharlinFeng/CoreHttp/bf3b098b831fc55fc3f4314be04bea70dbdbfcb3/CoreHttp.xcodeproj/project.xcworkspace/xcuserdata/Charlin.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/CoreHttp.xcodeproj/project.xcworkspace/xcuserdata/huaxi100.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CharlinFeng/CoreHttp/bf3b098b831fc55fc3f4314be04bea70dbdbfcb3/CoreHttp.xcodeproj/project.xcworkspace/xcuserdata/huaxi100.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/CoreHttp.xcodeproj/xcuserdata/Charlin.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
8 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/CoreHttp.xcodeproj/xcuserdata/Charlin.xcuserdatad/xcschemes/CoreHttp.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
29 |
35 |
36 |
37 |
38 |
39 |
44 |
45 |
47 |
53 |
54 |
55 |
56 |
57 |
63 |
64 |
65 |
66 |
75 |
77 |
83 |
84 |
85 |
86 |
87 |
88 |
94 |
96 |
102 |
103 |
104 |
105 |
107 |
108 |
111 |
112 |
113 |
--------------------------------------------------------------------------------
/CoreHttp.xcodeproj/xcuserdata/Charlin.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | CoreHttp.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | EE20AFA11AA4668A009CC587
16 |
17 | primary
18 |
19 |
20 | EE20AFBA1AA4668A009CC587
21 |
22 | primary
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/CoreHttp.xcodeproj/xcuserdata/huaxi100.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
--------------------------------------------------------------------------------
/CoreHttp.xcodeproj/xcuserdata/huaxi100.xcuserdatad/xcschemes/CoreHttp.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
29 |
35 |
36 |
37 |
38 |
39 |
44 |
45 |
47 |
53 |
54 |
55 |
56 |
57 |
63 |
64 |
65 |
66 |
75 |
76 |
82 |
83 |
84 |
85 |
86 |
87 |
93 |
94 |
100 |
101 |
102 |
103 |
105 |
106 |
109 |
110 |
111 |
--------------------------------------------------------------------------------
/CoreHttp.xcodeproj/xcuserdata/huaxi100.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | CoreHttp.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | EE20AFA11AA4668A009CC587
16 |
17 | primary
18 |
19 |
20 | EE20AFBA1AA4668A009CC587
21 |
22 | primary
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/CoreHttp/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // CoreHttp
4 | //
5 | // Created by muxi on 15/3/2.
6 | // Copyright (c) 2015年 muxi. 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 |
--------------------------------------------------------------------------------
/CoreHttp/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // CoreHttp
4 | //
5 | // Created by muxi on 15/3/2.
6 | // Copyright (c) 2015年 muxi. 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 |
20 | // Override point for customization after application launch.
21 | return YES;
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 throttle down OpenGL ES frame rates. Games should use this method to pause the game.
27 | }
28 |
29 | - (void)applicationDidEnterBackground:(UIApplication *)application {
30 | // 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.
31 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
32 | }
33 |
34 | - (void)applicationWillEnterForeground:(UIApplication *)application {
35 | // 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.
36 | }
37 |
38 | - (void)applicationDidBecomeActive:(UIApplication *)application {
39 | // 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.
40 | }
41 |
42 | - (void)applicationWillTerminate:(UIApplication *)application {
43 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
44 | }
45 |
46 | @end
47 |
--------------------------------------------------------------------------------
/CoreHttp/Base.lproj/LaunchScreen.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
20 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/CoreHttp/CoreHttp/CoreHttp.h:
--------------------------------------------------------------------------------
1 | //
2 | // ToolConnection.h
3 | //
4 | // Created by muxi on 14/10/22.
5 | // Copyright (c) 2014年 muxi. All rights reserved.
6 | // 全新的网络请求工具类:2.0版本(更新于2015.01.28)
7 |
8 | #import
9 | #import
10 | #import "UploadFile.h"
11 |
12 | typedef enum{
13 |
14 | //请求正常,无错误
15 | CoreHttpErrorTypeNull=0,
16 |
17 | //请求时出错,可能是URL不正确
18 | CoreHttpErrorTypeURLConnectionError,
19 |
20 | //请求时出错,服务器未返回正常的状态码:200
21 | CoreHttpErrorTypeStatusCodeError,
22 |
23 | //请求回的Data在解析前就是nil,导致请求无效,无法后续JSON反序列化。
24 | CoreHttpErrorTypeDataNilError,
25 |
26 | //data在JSON反序列化时出错
27 | CoreHttpErrorTypeDataSerializationError,
28 |
29 | //无网络连接
30 | CoreHttpErrorTypeNoNetWork,
31 |
32 | //服务器请求成功,但抛出错误
33 | CoreHttpErrorTypeServiceRetrunErrorStatus,
34 |
35 | /**
36 | * 以下是文件上传中的错误类型
37 | */
38 | CoreHttpErrorTypeUploadDataNil, //什么都没有上传
39 |
40 |
41 | }CoreHttpErrorType; //错误类型定义
42 |
43 |
44 |
45 |
46 |
47 | typedef void(^SuccessBlock)(id obj);
48 |
49 | typedef void(^ErrorBlock)(CoreHttpErrorType errorType, NSString *errorMsg);
50 |
51 |
52 |
53 | @interface CoreHttp : NSObject
54 |
55 |
56 | /**
57 | * GET:
58 | * params中可指明参数类型
59 | */
60 | +(NSURLSessionDataTask *)getUrl:(NSString *)urlString params:(id)params success:(SuccessBlock)successBlock errorBlock:(ErrorBlock)errorBlock;
61 |
62 |
63 | /**
64 | * POST:
65 | */
66 | +(NSURLSessionDataTask *)postUrl:(NSString *)urlString params:(id)params success:(SuccessBlock)successBlock errorBlock:(ErrorBlock)errorBlock;
67 |
68 |
69 |
70 | /**
71 | * 文件上传
72 | * @params: 普通参数
73 | * @files : 文件数据,里面装的都是UploadFile对象
74 | */
75 | +(void)uploadUrl:(NSString *)uploadUrl params:(id)params files:(NSArray *)files success:(SuccessBlock)successBlock errorBlock:(ErrorBlock)errorBlock delegate:(id)delegate;
76 |
77 |
78 |
79 | @end
80 |
--------------------------------------------------------------------------------
/CoreHttp/CoreHttp/NSString+CoreHttp/NSString+CoreHttp.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSString+CoreHttp.h
3 | // CoreHttp
4 | //
5 | // Created by muxi on 15/3/2.
6 | // Copyright (c) 2015年 muxi. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface NSString (CoreHttp)
12 |
13 | /**
14 | * 处理json格式的字符串中的换行符、回车符
15 | */
16 | -(NSString *)deleteSpecialCode;
17 |
18 |
19 |
20 |
21 | @end
22 |
--------------------------------------------------------------------------------
/CoreHttp/CoreHttp/NSString+CoreHttp/NSString+CoreHttp.m:
--------------------------------------------------------------------------------
1 | //
2 | // NSString+CoreHttp.m
3 | // CoreHttp
4 | //
5 | // Created by muxi on 15/3/2.
6 | // Copyright (c) 2015年 muxi. All rights reserved.
7 | //
8 |
9 | #import "NSString+CoreHttp.h"
10 |
11 | @implementation NSString (CoreHttp)
12 |
13 |
14 |
15 | /**
16 | * 处理json格式的字符串中的换行符、回车符
17 | */
18 | -(NSString *)deleteSpecialCode {
19 |
20 | NSString *string = [self stringByReplacingOccurrencesOfString:@"\r" withString:@""];
21 |
22 | string = [string stringByReplacingOccurrencesOfString:@"\n" withString:@""];
23 |
24 | string = [string stringByReplacingOccurrencesOfString:@"\n" withString:@""];
25 |
26 | string = [string stringByReplacingOccurrencesOfString:@"\t" withString:@""];
27 |
28 | string = [string stringByReplacingOccurrencesOfString:@" " withString:@""];
29 |
30 | string = [string stringByReplacingOccurrencesOfString:@"(" withString:@""];
31 |
32 | string = [string stringByReplacingOccurrencesOfString:@")" withString:@""];
33 |
34 | return string;
35 | }
36 |
37 | @end
38 |
--------------------------------------------------------------------------------
/CoreHttp/CoreHttp/Upload/NSData+MimeType.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSData+MimeType.h
3 | // CoreHttp
4 | //
5 | // Created by muxi on 15/3/2.
6 | // Copyright (c) 2015年 muxi. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface NSData (MimeType)
12 |
13 | @property (nonatomic,copy,readonly) NSString *mimeType;
14 |
15 |
16 | @end
17 |
--------------------------------------------------------------------------------
/CoreHttp/CoreHttp/Upload/NSData+MimeType.m:
--------------------------------------------------------------------------------
1 | //
2 | // NSData+MimeType.m
3 | // CoreHttp
4 | //
5 | // Created by muxi on 15/3/2.
6 | // Copyright (c) 2015年 muxi. All rights reserved.
7 | //
8 |
9 | #import "NSData+MimeType.h"
10 |
11 | @implementation NSData (MimeType)
12 |
13 |
14 | -(NSString *)mimeType{
15 |
16 | uint8_t c;
17 |
18 | [self getBytes:&c length:1];
19 |
20 | NSString *mimeType=nil;
21 |
22 | switch (c) {
23 | case 0xFF:
24 | mimeType = @"image/jpeg";
25 | break;
26 | case 0x89:
27 | mimeType = @"image/png";
28 | break;
29 | case 0x47:
30 | mimeType = @"image/gif";
31 | break;
32 | case 0x49:
33 | case 0x4D:
34 | mimeType = @"image/tiff";
35 | break;
36 | }
37 |
38 |
39 | if(mimeType==nil){
40 | mimeType=@"image/jpeg";
41 | NSLog(@"Warnning:请注意,根据NSData获取图片的MimeType的时候出现错误:没有获取到值,框架默认‘image/jpeg’替换!");
42 | }
43 |
44 | return mimeType;
45 | }
46 |
47 |
48 |
49 | @end
50 |
--------------------------------------------------------------------------------
/CoreHttp/CoreHttp/Upload/NSData+Param.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSData+Param.h
3 | // Upload
4 | //
5 | // Created by muxi on 15/2/12.
6 | // Copyright (c) 2015年 muxi. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface NSData (Param)
12 |
13 |
14 |
15 |
16 | /**
17 | * 文件参数
18 | *
19 | * @param files 文件参数对象数组
20 | *
21 | * @return data
22 | */
23 | +(NSData *)uploadParameterForFiles:(NSArray *)files;
24 |
25 |
26 |
27 |
28 | /**
29 | * 普通参数对象:一个键值对就是一个UploadParameter对象
30 | *
31 | * @param normalParams 普通参数字典
32 | *
33 | * @return data
34 | */
35 | +(NSData *)uploadParameterForNormalParams:(NSDictionary *)normalParams;
36 |
37 |
38 |
39 |
40 | /**
41 | * 结束参数对象
42 | */
43 | +(NSData *)uploadParameterForEnd;
44 |
45 |
46 |
47 |
48 | /**
49 | * 返回boundary
50 | */
51 | +(NSString *)boundary;
52 |
53 |
54 |
55 | @end
56 |
--------------------------------------------------------------------------------
/CoreHttp/CoreHttp/Upload/NSString+File.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSString+File.h
3 | // Upload
4 | //
5 | // Created by muxi on 15/2/12.
6 | // Copyright (c) 2015年 muxi. All rights reserved.
7 | // 字符串数据转data,和文件操作无关
8 |
9 | #import
10 |
11 | @interface NSString (File)
12 |
13 |
14 | /**
15 | * 字符串转data
16 | */
17 | -(NSData *)strData;
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 | @end
26 |
--------------------------------------------------------------------------------
/CoreHttp/CoreHttp/Upload/NSString+File.m:
--------------------------------------------------------------------------------
1 | //
2 | // NSString+File.m
3 | // Upload
4 | //
5 | // Created by muxi on 15/2/12.
6 | // Copyright (c) 2015年 muxi. All rights reserved.
7 | //
8 |
9 | #import "NSString+File.h"
10 |
11 | @implementation NSString (File)
12 |
13 | -(NSData *)strData{
14 |
15 | NSRange range = [self rangeOfString:@"file://"];
16 |
17 | if(range.length!=0){
18 |
19 | NSLog(@"请注意:您可能是想要获取本地文件(%@)数据,而不是将此URL地址直接转为对应的NSData。",self);
20 | }
21 |
22 | return [self dataUsingEncoding:NSUTF8StringEncoding];
23 | }
24 |
25 |
26 |
27 | @end
28 |
--------------------------------------------------------------------------------
/CoreHttp/CoreHttp/Upload/NSURL+File.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSURL+File.h
3 | // Upload
4 | //
5 | // Created by muxi on 15/2/12.
6 | // Copyright (c) 2015年 muxi. All rights reserved.
7 | // 本地文件资源转Data操作
8 |
9 | #import
10 |
11 | @interface NSURL (File)
12 |
13 |
14 | /**
15 | * 获取指定path的文件的mimeType
16 | */
17 | -(NSString *)mimeType;
18 |
19 |
20 | /**
21 | * 获取指定path的文件的data
22 | */
23 | -(NSData *)dataForFileResource;
24 |
25 |
26 | @end
27 |
--------------------------------------------------------------------------------
/CoreHttp/CoreHttp/Upload/NSURL+File.m:
--------------------------------------------------------------------------------
1 | //
2 | // NSURL+File.m
3 | // Upload
4 | //
5 | // Created by muxi on 15/2/12.
6 | // Copyright (c) 2015年 muxi. All rights reserved.
7 | //
8 |
9 | #import "NSURL+File.h"
10 |
11 | @implementation NSURL (File)
12 |
13 | /**
14 | * 获取指定文件的mimeType
15 | */
16 | -(NSString *)mimeType{
17 |
18 | NSURLRequest *request=[NSURLRequest requestWithURL:self];
19 |
20 | NSURLResponse *response=nil;
21 |
22 | NSError *error=nil;
23 |
24 | //使用同步请求,访问本地文件
25 | [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
26 |
27 | if(error!=nil){
28 | NSLog(@"获取指定文件的mimeType时出错,出错信息:%@出错文件:%@",error.localizedDescription,self);
29 | return nil;
30 | }
31 |
32 | NSString *mimeType=response.MIMEType;
33 |
34 | if(mimeType==nil || mimeType.length==0){
35 | NSLog(@"获取指定文件的mimeType时为空:%@出错文件:%@",mimeType,self);
36 | return nil;
37 | }
38 |
39 | return mimeType;
40 | }
41 |
42 |
43 |
44 |
45 | /**
46 | * 获取指定path的文件的data
47 | */
48 | -(NSData *)dataForFileResource{
49 |
50 | NSURLRequest *request=[NSURLRequest requestWithURL:self];
51 |
52 | NSURLResponse *response=nil;
53 |
54 | NSError *error=nil;
55 |
56 | //使用同步请求,访问本地文件
57 | NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
58 |
59 | if(error!=nil){
60 | NSLog(@"获取指定文件的data数据时出错,出错信息:%@出错文件:%@",error.localizedDescription,self);
61 | return nil;
62 | }
63 |
64 | if(data==nil || data.length==0){
65 | NSLog(@"获取指定文件的data数据为空,出错文件:%@",self);
66 | return nil;
67 | }
68 |
69 | return data;
70 | }
71 |
72 |
73 |
74 | @end
75 |
--------------------------------------------------------------------------------
/CoreHttp/CoreHttp/Upload/UploadFile.h:
--------------------------------------------------------------------------------
1 | //
2 | // UploadFile.h
3 | // Upload
4 | //
5 | // Created by muxi on 15/2/11.
6 | // Copyright (c) 2015年 muxi. All rights reserved.
7 | // 上传的文件
8 |
9 | #import
10 |
11 | @interface UploadFile : NSObject
12 |
13 | @property (nonatomic,strong) NSString *key; //文件上传对应的key,如果不传默认放入file[]
14 |
15 | @property (nonatomic,copy) NSURL *url; //文件本地路径
16 |
17 | @property (nonatomic,copy) NSString *name; //文件名
18 |
19 | @property (nonatomic,copy) NSString *mimeType; //文件类型
20 |
21 | @property (nonatomic,assign) NSInteger size; //文件大小(服务器自动获取)
22 |
23 | @property (nonatomic,strong) NSData *data; //文件的二进制数据
24 |
25 | @property (nonatomic,copy) NSString *tmp_name; //临时文件名(服务器自动获取)
26 |
27 | @property (nonatomic,copy) NSString *error; //文件错误信息(服务器自动获取)
28 |
29 |
30 | /**
31 | * 文件:基于本地URL创建
32 | */
33 | +(instancetype)fileWithKey:(NSString *)key url:(NSURL *)url;
34 |
35 |
36 |
37 | /**
38 | * 自动获取mimeType
39 | *
40 | * @param key key:服务器对应的key
41 | * @param data 图片二进制数据
42 | * @param name 图片名称
43 | *
44 | * @return 实例
45 | */
46 | +(instancetype)fileWithKey:(NSString *)key data:(NSData *)data name:(NSString *)name;
47 |
48 |
49 |
50 |
51 | /**
52 | * 如果自动处理mimeType出错,建议使用此方法,一般不使用此方法
53 | */
54 | +(instancetype)fileWithKey:(NSString *)key data:(NSData *)data mimeType:(NSString *)mimeType name:(NSString *)name;
55 |
56 |
57 |
58 | @end
59 |
--------------------------------------------------------------------------------
/CoreHttp/CoreHttp/Upload/UploadFile.m:
--------------------------------------------------------------------------------
1 | //
2 | // UploadFile.m
3 | // Upload
4 | //
5 | // Created by muxi on 15/2/11.
6 | // Copyright (c) 2015年 muxi. All rights reserved.
7 | //
8 |
9 | #import "UploadFile.h"
10 | #import "NSURL+File.h"
11 | #import "NSString+File.h"
12 | #import "NSData+MimeType.h"
13 |
14 | @implementation UploadFile
15 |
16 |
17 | /**
18 | * 文件:通过url创建
19 | */
20 | +(instancetype)fileWithKey:(NSString *)key url:(NSURL *)url{
21 |
22 | UploadFile *file=[[UploadFile alloc] init];
23 |
24 | if(url==nil){
25 | NSLog(@"初始化文件时传入了一个空的本地URL资源地址,请检查!");
26 | return file;
27 | }
28 |
29 | //key
30 | file.key=key;
31 |
32 | //保存路径
33 | file.url=url;
34 |
35 | //获取文件名
36 | file.name=[url.absoluteString lastPathComponent];
37 |
38 | //获取mimeType
39 | file.mimeType=[url mimeType];
40 |
41 | //获取data
42 | file.data=[url dataForFileResource];
43 |
44 | return file;
45 | }
46 |
47 |
48 |
49 | /**
50 | * 自动获取mimeType
51 | *
52 | * @param key key:服务器对应的key
53 | * @param data 图片二进制数据
54 | * @param name 图片名称
55 | *
56 | * @return 实例
57 | */
58 | +(instancetype)fileWithKey:(NSString *)key data:(NSData *)data name:(NSString *)name{
59 |
60 | UploadFile *file=[[UploadFile alloc] init];
61 |
62 | //key
63 | file.key=key;
64 |
65 | //data
66 | file.data=data;
67 |
68 | //name
69 | file.name=name;
70 |
71 | //mimeType
72 | file.mimeType=data.mimeType;
73 |
74 | return file;
75 | }
76 |
77 |
78 | /**
79 | * 如果自动处理mimeType出错,可尝试使用此方法,一般不使用此方法
80 | */
81 | +(instancetype)fileWithKey:(NSString *)key data:(NSData *)data mimeType:(NSString *)mimeType name:(NSString *)name{
82 |
83 | UploadFile *file=[self fileWithKey:key data:data name:name];
84 |
85 | //mimeType
86 | file.mimeType=mimeType;
87 |
88 | return file;
89 | }
90 |
91 | -(NSString *)description{
92 | return [NSString stringWithFormat:@"key=%@,name=%@,mimeType=%@",self.key,self.name,self.mimeType];
93 | }
94 |
95 | -(NSString *)key{
96 |
97 | if(_key==nil){
98 |
99 | _key=@"file[]";
100 | }
101 |
102 | return _key;
103 | }
104 |
105 | @end
106 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/APPHttp/APPHttp.h:
--------------------------------------------------------------------------------
1 | //
2 | // APPHttp.h
3 | // 4s
4 | //
5 | // Created by muxi on 15/3/10.
6 | // Copyright (c) 2015年 muxi. All rights reserved.
7 | // 项目网络请求工具,每个需要都需要根据实际情况来配置
8 |
9 | #import
10 | #import
11 | #import "CoreHttp.h"
12 | #import "CoreStatusBtn.h"
13 | #import "APPHttpType.h"
14 | #import "APPHttpSingleton.h"
15 |
16 | #define AppHttpTokenDeprecatedNoti @"AppHttpTokenDeprecatedNoti"
17 |
18 |
19 | @interface APPHttp : NSObject
20 | HMSingletonH(APPHttp)
21 |
22 |
23 |
24 |
25 | /**
26 | * GET:
27 | * params中可指明参数类型
28 | * target:
29 | * APPHttpTypeStatusView :view
30 | * APPHttpTypeSVP :nil
31 | * APPHttpTypeBtn :btn
32 | */
33 | +(void)getUrl:(NSString *)urlString params:(id)params target:(id)target type:(APPHttpType)type success:(SuccessBlock)successBlock errorBlock:(ErrorBlock)errorBlock;
34 |
35 |
36 |
37 | /**
38 | * POST:
39 | * APPHttpTypeStatusView :view
40 | * APPHttpTypeSVP :nil
41 | * APPHttpTypeBtn :btn
42 | */
43 | +(void)postUrl:(NSString *)urlString params:(id)params target:(id)target type:(APPHttpType)type success:(SuccessBlock)successBlock errorBlock:(ErrorBlock)errorBlock;
44 |
45 |
46 |
47 | /**
48 | * UPLOAD:
49 | * APPHttpTypeStatusView :view
50 | * APPHttpTypeSVP :nil
51 | * APPHttpTypeBtn :btn
52 | */
53 | +(void)uploadUrl:(NSString *)uploadUrl params:(id)params files:(NSArray *)files target:(id)target type:(APPHttpType)type progressBlock:(void(^)(CGFloat p))progressBlock success:(SuccessBlock)successBlock errorBlock:(ErrorBlock)errorBlock;
54 |
55 |
56 | /** 取出task */
57 | +( NSURLSessionDataTask *)taskWithUrl:(NSString *)url;
58 |
59 | @end
60 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/APPHttp/Lib/APPHttpType.h:
--------------------------------------------------------------------------------
1 | //
2 | // APPHttpType.h
3 | // CoreHttp
4 | //
5 | // Created by 成林 on 15/6/7.
6 | // Copyright (c) 2015年 muxi. All rights reserved.
7 | //
8 |
9 | #ifndef CoreHttp_APPHttpType_h
10 | #define CoreHttp_APPHttpType_h
11 |
12 | /** 指示器类型 */
13 | typedef enum{
14 |
15 | //None
16 | APPHttpTypeNone = 0,
17 |
18 | //StatusView
19 | APPHttpTypeStatusView,
20 |
21 | //SVP
22 | APPHttpTypeSVP,
23 |
24 | //Btn
25 | APPHttpTypeBtn,
26 |
27 | }APPHttpType;
28 |
29 |
30 |
31 | /** 请求方式 */
32 | typedef enum{
33 |
34 | //GET
35 | APPHttpMethodGET = 0,
36 |
37 | //POST
38 | APPHttpMethodPOST,
39 |
40 | }APPHttpMethod;
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 | #endif
56 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/APPHttp/Lib/Singleton/APPHttpSingleton.h:
--------------------------------------------------------------------------------
1 | // .h文件
2 | #define HMSingletonH(name) + (instancetype)shared##name;
3 |
4 | // .m文件
5 | #if __has_feature(objc_arc)
6 |
7 | #define HMSingletonM(name) \
8 | static id _instace; \
9 | \
10 | + (id)allocWithZone:(struct _NSZone *)zone \
11 | { \
12 | static dispatch_once_t onceToken; \
13 | dispatch_once(&onceToken, ^{ \
14 | _instace = [super allocWithZone:zone]; \
15 | }); \
16 | return _instace; \
17 | } \
18 | \
19 | + (instancetype)shared##name \
20 | { \
21 | static dispatch_once_t onceToken; \
22 | dispatch_once(&onceToken, ^{ \
23 | _instace = [[self alloc] init]; \
24 | }); \
25 | return _instace; \
26 | } \
27 | \
28 | - (id)copyWithZone:(NSZone *)zone \
29 | { \
30 | return _instace; \
31 | }
32 |
33 | #else
34 |
35 | #define HMSingletonM(name) \
36 | static id _instace; \
37 | \
38 | + (id)allocWithZone:(struct _NSZone *)zone \
39 | { \
40 | static dispatch_once_t onceToken; \
41 | dispatch_once(&onceToken, ^{ \
42 | _instace = [super allocWithZone:zone]; \
43 | }); \
44 | return _instace; \
45 | } \
46 | \
47 | + (instancetype)shared##name \
48 | { \
49 | static dispatch_once_t onceToken; \
50 | dispatch_once(&onceToken, ^{ \
51 | _instace = [[self alloc] init]; \
52 | }); \
53 | return _instace; \
54 | } \
55 | \
56 | - (id)copyWithZone:(NSZone *)zone \
57 | { \
58 | return _instace; \
59 | } \
60 | \
61 | - (oneway void)release { } \
62 | - (id)retain { return self; } \
63 | - (NSUInteger)retainCount { return 1;} \
64 | - (id)autorelease { return self;}
65 |
66 | #endif
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreBtn/Anim/AnimForCoreBtn.h:
--------------------------------------------------------------------------------
1 | //
2 | // AnimForCoreBtn.h
3 | // CoreBtn
4 | //
5 | // Created by 沐汐 on 15-3-2.
6 | // Copyright (c) 2015年 沐汐. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AnimForCoreBtn : CAAnimation
12 |
13 |
14 | /**
15 | * 摇动动画
16 | *
17 | * @return 动画对象
18 | */
19 | +(CAKeyframeAnimation *)shake;
20 |
21 |
22 | @end
23 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreBtn/Anim/AnimForCoreBtn.m:
--------------------------------------------------------------------------------
1 | //
2 | // AnimForCoreBtn.m
3 | // CoreBtn
4 | //
5 | // Created by 沐汐 on 15-3-2.
6 | // Copyright (c) 2015年 沐汐. All rights reserved.
7 | //
8 |
9 | #import "AnimForCoreBtn.h"
10 |
11 | @implementation AnimForCoreBtn
12 |
13 | /**
14 | * 摇动动画
15 | *
16 | * @return 动画对象
17 | */
18 | +(CAKeyframeAnimation *)shake{
19 |
20 | CAKeyframeAnimation *kfa=[CAKeyframeAnimation animationWithKeyPath:@"transform.rotation"];
21 |
22 | //值
23 | kfa.values=@[@0.08f,@(0),@(-0.08f),@(0),@0.08f,@(0),@(-0.08f)];
24 |
25 | //设置时间
26 | kfa.duration=0.07f;
27 |
28 | //是否重复
29 | kfa.repeatCount=4.0f;
30 |
31 | //是否反转
32 | kfa.autoreverses=YES;
33 |
34 | //完成移除
35 | kfa.removedOnCompletion=YES;
36 |
37 | return kfa;
38 | }
39 |
40 |
41 |
42 | @end
43 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreBtn/CoreBtn.h:
--------------------------------------------------------------------------------
1 | //
2 | // BaseBtn.h
3 | // Drivers
4 | //
5 | // Created by muxi on 15/2/6.
6 | // Copyright (c) 2015年 muxi. All rights reserved.
7 | // 自定义的按钮
8 | // 此按钮可以设置不同状态下的背景色
9 |
10 | #import
11 |
12 | #define rgb(r,g,b) [UIColor colorWithRed:r/255.0f green:g/255.0f blue:b/255.0f alpha:1.0f]
13 |
14 | @interface CoreBtn : UIButton
15 |
16 | //普通状态下的颜色
17 | @property (nonatomic,strong) UIColor *backgroundColorForNormal;
18 |
19 | //高亮状态下的颜色
20 | @property (nonatomic,strong) UIColor *backgroundColorForHighlighted;
21 |
22 | //不可用状态下的颜色
23 | @property (nonatomic,strong) UIColor *backgroundColorForDisabled;
24 |
25 | //被选中状态下的颜色
26 | @property (nonatomic,strong) UIColor *backgroundColorForSelected;
27 |
28 | //字体大小
29 | @property (nonatomic,assign) CGFloat fontPoint;
30 |
31 |
32 | @end
33 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreBtn/CoreBtn.m:
--------------------------------------------------------------------------------
1 | //
2 | // BaseBtn.m
3 | // Drivers
4 | //
5 | // Created by muxi on 15/2/6.
6 | // Copyright (c) 2015年 muxi. All rights reserved.
7 | //
8 |
9 | #import "CoreBtn.h"
10 | #import "UIImage+ColorForBtn.h"
11 |
12 | @implementation CoreBtn
13 |
14 |
15 |
16 | #pragma mark 普通状态
17 | -(void)setBackgroundColorForNormal:(UIColor *)backgroundColorForNormal{
18 |
19 | _backgroundColorForNormal=backgroundColorForNormal;
20 | [self setBackgroundImage:[UIImage imageFromContextWithColor:backgroundColorForNormal] forState:UIControlStateNormal];
21 | if(_backgroundColorForDisabled==nil) self.backgroundColorForDisabled=backgroundColorForNormal;
22 | }
23 |
24 |
25 | #pragma mark 高亮状态
26 | -(void)setBackgroundColorForHighlighted:(UIColor *)backgroundColorForHighlighted{
27 | _backgroundColorForHighlighted=backgroundColorForHighlighted;
28 | [self setBackgroundImage:[UIImage imageFromContextWithColor:backgroundColorForHighlighted] forState:UIControlStateHighlighted];
29 | }
30 |
31 |
32 |
33 | #pragma mark 选中状态
34 | -(void)setBackgroundColorForSelected:(UIColor *)backgroundColorForSelected{
35 | _backgroundColorForSelected=backgroundColorForSelected;
36 | [self setBackgroundImage:[UIImage imageFromContextWithColor:backgroundColorForSelected] forState:UIControlStateSelected];
37 | }
38 |
39 |
40 | #pragma mark 不可用状态
41 | -(void)setBackgroundColorForDisabled:(UIColor *)backgroundColorForDisabled{
42 | _backgroundColorForDisabled=backgroundColorForDisabled;
43 | [self setBackgroundImage:[UIImage imageFromContextWithColor:backgroundColorForDisabled] forState:UIControlStateDisabled];
44 | }
45 |
46 |
47 |
48 | #pragma mark 字体大小
49 | -(void)setFontPoint:(CGFloat)fontPoint{
50 | _fontPoint=fontPoint;
51 | self.titleLabel.font=[UIFont systemFontOfSize:fontPoint];
52 | }
53 |
54 |
55 | @end
56 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreBtn/CoreStatusBtn.h:
--------------------------------------------------------------------------------
1 | //
2 | // CoreStatusBtn.h
3 | // CoreBtn
4 | //
5 | // Created by 沐汐 on 15-3-2.
6 | // Copyright (c) 2015年 沐汐. All rights reserved.
7 | // 具有状态的按钮,用来解决网络请求中的界面整体化以及逻辑化
8 | // 本按钮具有各种状态,在网络请求中,在不同的网络请求状态中设置按钮对应的状态达到指示网络请求状态的目的
9 | // 本按钮纯界面显示,不关联任何block过程。
10 |
11 |
12 |
13 | #import "CoreBtn.h"
14 |
15 |
16 | typedef enum{
17 |
18 | //最普通的状态,此状态和CoreBtn是一样的,具有可交互性
19 | CoreStatusBtnStatusNormal=0,
20 |
21 | //处理中
22 | CoreStatusBtnStatusProgress,
23 |
24 | //结果成功
25 | CoreStatusBtnStatusSuccess,
26 |
27 | //结果失败
28 | CoreStatusBtnStatusFalse,
29 |
30 | }CoreStatusBtnStatus;
31 |
32 |
33 |
34 | @interface CoreStatusBtn : CoreBtn
35 |
36 |
37 |
38 | /**
39 | * 状态
40 | */
41 | @property (nonatomic,assign) CoreStatusBtnStatus status;
42 |
43 |
44 |
45 | /**
46 | * 提示文字
47 | */
48 | @property (nonatomic,copy) NSString *msg;
49 |
50 |
51 |
52 |
53 | @end
54 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreBtn/CoreStatusBtn.m:
--------------------------------------------------------------------------------
1 | //
2 | // CoreStatusBtn.m
3 | // CoreBtn
4 | //
5 | // Created by 沐汐 on 15-3-2.
6 | // Copyright (c) 2015年 沐汐. All rights reserved.
7 | //
8 |
9 | #import "CoreStatusBtn.h"
10 | #import "CoreStatusBtnMaskView.h"
11 | #import "AnimForCoreBtn.h"
12 |
13 | @interface CoreStatusBtn ()
14 |
15 | //遮罩层
16 | @property (nonatomic,strong) CoreStatusBtnMaskView *maskView;
17 |
18 | @end
19 |
20 |
21 | @implementation CoreStatusBtn
22 |
23 |
24 |
25 | -(void)setStatus:(CoreStatusBtnStatus)status{
26 |
27 | dispatch_async(dispatch_get_main_queue(), ^{
28 |
29 | _status=status;
30 |
31 | self.enabled=(CoreStatusBtnStatusNormal==status || CoreStatusBtnStatusSuccess==status);
32 |
33 | if(status==CoreStatusBtnStatusFalse){
34 | //执行一个失败动画
35 | [self.layer addAnimation:[AnimForCoreBtn shake] forKey:@"shake"];
36 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5.0f * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
37 | self.status=CoreStatusBtnStatusNormal;
38 | });
39 | }
40 |
41 | self.maskView.status=status;
42 | });
43 | }
44 |
45 |
46 |
47 | -(void)setMsg:(NSString *)msg{
48 |
49 | _msg=msg;
50 |
51 | dispatch_async(dispatch_get_main_queue(), ^{
52 | self.maskView.msg=msg;
53 | });
54 | }
55 |
56 |
57 | -(CoreStatusBtnMaskView *)maskView{
58 |
59 | if(_maskView==nil){
60 |
61 | _maskView=[CoreStatusBtnMaskView maskView];
62 | _maskView.statusBtn=self;
63 |
64 | [self addSubview:_maskView];
65 | }
66 |
67 | return _maskView;
68 | }
69 |
70 |
71 | @end
72 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreBtn/UIImage+ColorForBtn/UIImage+ColorForBtn.h:
--------------------------------------------------------------------------------
1 | //
2 | // UIImage+Color.h
3 | // 网易彩票2014MJ版
4 | //
5 | // Created by 沐汐 on 14-9-13.
6 | // Copyright (c) 2014年 沐汐. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface UIImage (ColorForBtn)
12 |
13 | //给我一种颜色,一个尺寸,我给你返回一个UIImage:不透明
14 | +(UIImage *)imageFromContextWithColor:(UIColor *)color;
15 | +(UIImage *)imageFromContextWithColor:(UIColor *)color size:(CGSize)size;
16 |
17 | @end
18 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreBtn/UIImage+ColorForBtn/UIImage+ColorForBtn.m:
--------------------------------------------------------------------------------
1 | //
2 | // UIImage+Color.m
3 | // 网易彩票2014MJ版
4 | //
5 | // Created by 沐汐 on 14-9-13.
6 | // Copyright (c) 2014年 沐汐. All rights reserved.
7 | //
8 |
9 | #import "UIImage+ColorForBtn.h"
10 |
11 | @implementation UIImage (Color)
12 |
13 |
14 | //给我一种颜色,一个尺寸,我给你返回一个UIImage
15 | +(UIImage *)imageFromContextWithColor:(UIColor *)color size:(CGSize)size{
16 |
17 | CGRect rect=(CGRect){{0.0f,0.0f},size};
18 |
19 | //开启一个图形上下文
20 | UIGraphicsBeginImageContextWithOptions(rect.size, NO, 0.0f);
21 |
22 | //获取图形上下文
23 | CGContextRef context=UIGraphicsGetCurrentContext();
24 |
25 | CGContextSetFillColorWithColor(context, color.CGColor);
26 |
27 | CGContextFillRect(context, rect);
28 |
29 | //获取图像
30 | UIImage *image=UIGraphicsGetImageFromCurrentImageContext();
31 |
32 | //关闭上下文
33 | UIGraphicsEndImageContext();
34 |
35 | return image;
36 | }
37 |
38 | +(UIImage *)imageFromContextWithColor:(UIColor *)color{
39 |
40 | CGSize size=CGSizeMake(1.0f, 1.0f);
41 |
42 | return [self imageFromContextWithColor:color size:size];
43 | }
44 |
45 |
46 |
47 | @end
48 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreBtn/View/CoreStatusBtnMaskView.h:
--------------------------------------------------------------------------------
1 | //
2 | // CoreStatusBtnMaskView.h
3 | // CoreBtn
4 | //
5 | // Created by 沐汐 on 15-3-2.
6 | // Copyright (c) 2015年 沐汐. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "CoreStatusBtn.h"
11 |
12 | @interface CoreStatusBtnMaskView : UIView
13 |
14 | /**
15 | * 状态
16 | */
17 | @property (nonatomic,assign) CoreStatusBtnStatus status;
18 |
19 |
20 | /**
21 | * 提示文字
22 | */
23 | @property (nonatomic,copy) NSString *msg;
24 |
25 | @property (nonatomic,weak) CoreStatusBtn *statusBtn;
26 |
27 |
28 |
29 |
30 | /**
31 | * maskView
32 | */
33 | +(instancetype)maskView;
34 |
35 |
36 |
37 | @end
38 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreBtn/View/CoreStatusBtnMaskView.m:
--------------------------------------------------------------------------------
1 | //
2 | // CoreStatusBtnMaskView.m
3 | // CoreBtn
4 | //
5 | // Created by 沐汐 on 15-3-2.
6 | // Copyright (c) 2015年 沐汐. All rights reserved.
7 | //
8 |
9 | #import "CoreStatusBtnMaskView.h"
10 |
11 | @interface CoreStatusBtnMaskView ()
12 |
13 | @property (weak, nonatomic) IBOutlet UILabel *msgLabel;
14 |
15 | @property (weak, nonatomic) IBOutlet UIActivityIndicatorView *iv;
16 |
17 |
18 | @end
19 |
20 |
21 | @implementation CoreStatusBtnMaskView
22 |
23 |
24 | /**
25 | * maskView
26 | */
27 | +(instancetype)maskView{
28 | return [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass(self) owner:nil options:nil] firstObject];
29 | }
30 |
31 | -(void)awakeFromNib{
32 |
33 | [super awakeFromNib];
34 |
35 | self.status=CoreStatusBtnStatusNormal;
36 | }
37 |
38 |
39 |
40 | -(void)didMoveToSuperview{
41 |
42 | [super didMoveToSuperview];
43 |
44 | self.translatesAutoresizingMaskIntoConstraints=NO;
45 |
46 | CoreStatusBtnMaskView *maskView=self;
47 |
48 | NSDictionary *views=NSDictionaryOfVariableBindings(maskView);
49 |
50 | [self.superview addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-0-[maskView]-0-|" options:0 metrics:nil views:views]];
51 | [self.superview addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-0-[maskView]-0-|" options:0 metrics:nil views:views]];
52 | }
53 |
54 | /**
55 | * 状态改变
56 | */
57 | -(void)setStatus:(CoreStatusBtnStatus)status{
58 |
59 | _status=status;
60 |
61 | [self actionWithStatus:status];
62 | }
63 |
64 | -(void)actionWithStatus:(CoreStatusBtnStatus)status{
65 |
66 | //性能优化
67 | if(CoreStatusBtnStatusProgress==status){
68 | [self.iv startAnimating];
69 | }else{
70 | [self.iv stopAnimating];
71 | }
72 |
73 | switch (status) {
74 | case CoreStatusBtnStatusNormal://正常
75 | [self statusNormal];
76 | break;
77 |
78 | case CoreStatusBtnStatusProgress://进度
79 | [self statusProgress];
80 | break;
81 |
82 | case CoreStatusBtnStatusSuccess://成功
83 | [self statusSuccess];
84 | break;
85 |
86 | case CoreStatusBtnStatusFalse://失败
87 | [self statusFalse];
88 | break;
89 |
90 | default:
91 | break;
92 | }
93 | }
94 |
95 | /**
96 | * 正常
97 | */
98 | -(void)statusNormal{
99 |
100 | //看不到自己
101 | self.alpha=.0f;
102 | }
103 |
104 | /**
105 | * 进度
106 | */
107 | -(void)statusProgress{
108 | [UIView animateWithDuration:0.5f animations:^{
109 | self.alpha=1.0f;
110 | }];
111 | }
112 |
113 | /**
114 | * 成功
115 | */
116 | -(void)statusSuccess{
117 | [UIView animateWithDuration:0.5f animations:^{
118 | self.alpha=.0f;
119 | }];
120 | }
121 |
122 | /**
123 | * 失败
124 | */
125 | -(void)statusFalse{
126 | [UIView animateWithDuration:0.5f animations:^{
127 | self.alpha=.0f;
128 | }];
129 | }
130 |
131 |
132 | -(void)setMsg:(NSString *)msg{
133 |
134 | _msg=msg;
135 |
136 | _msgLabel.text=msg;
137 | }
138 |
139 | -(void)setStatusBtn:(CoreStatusBtn *)statusBtn{
140 |
141 | _statusBtn=statusBtn;
142 |
143 | self.backgroundColor=statusBtn.backgroundColorForNormal;
144 |
145 | self.msgLabel.font=statusBtn.titleLabel.font;
146 |
147 | UIColor *color=[statusBtn titleColorForState:UIControlStateNormal];
148 | self.msgLabel.textColor=color;
149 | self.iv.color=color;
150 | }
151 |
152 |
153 |
154 | @end
155 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreBtn/View/CoreStatusBtnMaskView.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreIV/CoreIV.h:
--------------------------------------------------------------------------------
1 | //
2 | // CoreIV.h
3 | // CoreIV
4 | //
5 | // Created by 冯成林 on 15/11/28.
6 | // Copyright © 2015年 冯成林. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | typedef enum {
12 |
13 | IVTypeLoad,
14 |
15 | IVTypeError
16 |
17 | } IVType;
18 |
19 | @interface CoreIV : UIView
20 |
21 | /** 展示 */
22 | +(void)showWithType:(IVType)type view:(UIView *)view msg:(NSString *)msg failClickBlock:(void(^)())failClickBlock;
23 |
24 | /** 消失 */
25 | +(void)dismissFromView:(UIView *)view animated:(BOOL)animated;
26 |
27 |
28 |
29 |
30 | @end
31 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreIV/CoreIV.m:
--------------------------------------------------------------------------------
1 | //
2 | // CoreIV.m
3 | // CoreIV
4 | //
5 | // Created by 冯成林 on 15/11/28.
6 | // Copyright © 2015年 冯成林. All rights reserved.
7 | //
8 |
9 | #import "CoreIV.h"
10 | #import "DGActivityIndicatorView.h"
11 |
12 |
13 | @implementation UIView (layout)
14 |
15 | -(void)autoLayoutFillSuperView {
16 |
17 | if(self.superview == nil) {return;}
18 |
19 | self.translatesAutoresizingMaskIntoConstraints = NO;
20 |
21 | NSDictionary *views = @{@"v":self};
22 |
23 | NSArray *v_ver = [NSLayoutConstraint constraintsWithVisualFormat:@"V:|-0-[v]-0-|" options:0 metrics:nil views:views];
24 | NSArray *v_hor = [NSLayoutConstraint constraintsWithVisualFormat:@"H:|-0-[v]-0-|" options:0 metrics:nil views:views];
25 | [self.superview addConstraints:v_ver];[self.superview addConstraints:v_hor];
26 | }
27 |
28 | @end
29 |
30 |
31 |
32 | @interface CoreIV ()
33 |
34 | @property (weak, nonatomic) IBOutlet UIView *contentView;
35 |
36 | @property (weak, nonatomic) IBOutlet UILabel *msgLabel;
37 |
38 | @property (nonatomic,assign) IVType type;
39 |
40 | @property (nonatomic,weak) UIView *di;
41 |
42 | @property (nonatomic,copy) void (^FailBlock)();
43 |
44 | @end
45 |
46 |
47 |
48 |
49 | @implementation CoreIV
50 |
51 |
52 |
53 | /** 展示 */
54 | +(void)showWithType:(IVType)type view:(UIView *)view msg:(NSString *)msg failClickBlock:(void(^)())failClickBlock{
55 |
56 | [CoreIV dismissFromView:view animated:NO];
57 |
58 | dispatch_async(dispatch_get_main_queue(), ^{
59 |
60 |
61 |
62 | //创建view
63 | CoreIV *iv = [CoreIV iv];
64 |
65 | //设置
66 | iv.type = type;
67 | iv.msgLabel.text = msg;
68 | iv.FailBlock = failClickBlock;
69 |
70 | [view addSubview:iv];
71 |
72 | [iv autoLayoutFillSuperView];
73 | });
74 | }
75 |
76 | /** 消失 */
77 | +(void)dismissFromView:(UIView *)view animated:(BOOL)animated{
78 |
79 | dispatch_async(dispatch_get_main_queue(), ^{
80 | for (UIView *subView in view.subviews) {
81 |
82 | if(![subView isKindOfClass:[CoreIV class]]) continue;
83 |
84 | if(animated){
85 | [UIView animateWithDuration:0.3 animations:^{
86 | subView.alpha=0;
87 | } completion:^(BOOL finished) {
88 | [(CoreIV *)subView dismiss];return;
89 | }];
90 | }else{
91 | [(CoreIV *)subView dismiss];break;
92 | }
93 |
94 | }
95 | });
96 | }
97 |
98 |
99 | /** 内部处理 */
100 | +(instancetype)iv{
101 |
102 | return [[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class]) owner:nil options:nil].firstObject;
103 | }
104 |
105 | -(void)setType:(IVType)type {
106 |
107 | UIColor *tintColor = [UIColor grayColor];
108 | CGFloat size = 50;
109 |
110 | UIView *di = nil;
111 | if(type == IVTypeLoad) {
112 |
113 | DGActivityIndicatorView *di_temp = [[DGActivityIndicatorView alloc] initWithType:DGActivityIndicatorAnimationTypeBallBeat tintColor:tintColor size:size];
114 |
115 | di = di_temp;
116 |
117 | }else {
118 |
119 | di = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"CoreIV.bundle/smile_failed"]];
120 | }
121 |
122 | //记录
123 | self.di = di;
124 |
125 | [self.contentView addSubview:di];
126 |
127 | di.bounds = CGRectMake(0, 0, size * 2, size * 2);
128 |
129 | [di autoLayoutFillSuperView];
130 |
131 |
132 | if(self.type == IVTypeLoad){
133 |
134 | DGActivityIndicatorView *di_temp_2 = (DGActivityIndicatorView *)self.di;
135 |
136 | [di_temp_2 startAnimating];
137 | }
138 | }
139 |
140 | -(void)dismiss {
141 |
142 | if(self.type == IVTypeLoad){
143 |
144 | DGActivityIndicatorView *di_temp = (DGActivityIndicatorView *)self.di;
145 |
146 | [di_temp stopAnimating];
147 | }
148 |
149 | [self.di removeFromSuperview];
150 | [self removeFromSuperview];
151 | }
152 |
153 | -(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
154 |
155 | if(self.FailBlock != nil) self.FailBlock();
156 | }
157 |
158 | @end
159 |
160 |
161 |
162 |
163 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreIV/CoreIV.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreIV/Lib/CoreIV.bundle/smile_failed@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CharlinFeng/CoreHttp/bf3b098b831fc55fc3f4314be04bea70dbdbfcb3/CoreHttp/FrameWorks/CoreIV/Lib/CoreIV.bundle/smile_failed@2x.png
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreIV/Lib/CoreIV.bundle/smile_failed@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CharlinFeng/CoreHttp/bf3b098b831fc55fc3f4314be04bea70dbdbfcb3/CoreHttp/FrameWorks/CoreIV/Lib/CoreIV.bundle/smile_failed@3x.png
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreIV/Lib/DGActivityIndicatorView/Animations/DGActivityIndicatorBallBeatAnimation.h:
--------------------------------------------------------------------------------
1 | //
2 | // DGActivityIndicatorBallBeatAnimation.h
3 | // DGActivityIndicatorExample
4 | //
5 | // Created by Nguyen Vinh on 7/20/15.
6 | // Copyright (c) 2015 Danil Gontovnik. All rights reserved.
7 | //
8 |
9 | #import "DGActivityIndicatorAnimationProtocol.h"
10 |
11 | @interface DGActivityIndicatorBallBeatAnimation : NSObject
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreIV/Lib/DGActivityIndicatorView/Animations/DGActivityIndicatorBallBeatAnimation.m:
--------------------------------------------------------------------------------
1 | //
2 | // DGActivityIndicatorBallBeatAnimation.m
3 | // DGActivityIndicatorExample
4 | //
5 | // Created by Nguyen Vinh on 7/20/15.
6 | // Copyright (c) 2015 Danil Gontovnik. All rights reserved.
7 | //
8 |
9 | #import "DGActivityIndicatorBallBeatAnimation.h"
10 |
11 | @implementation DGActivityIndicatorBallBeatAnimation
12 |
13 | - (void)setupAnimationInLayer:(CALayer *)layer withSize:(CGSize)size tintColor:(UIColor *)tintColor {
14 | CGFloat duration = 0.7f;
15 | NSArray *beginTimes = @[@0.35f, @0.0f, @0.35f];
16 | CGFloat circleSpacing = 2.0f;
17 | CGFloat circleSize = (size.width - circleSpacing * 2) / 3;
18 | CGFloat x = (layer.bounds.size.width - size.width) / 2;
19 | CGFloat y = (layer.bounds.size.height - circleSize) / 2;
20 |
21 | // Scale animation
22 | CAKeyframeAnimation *scaleAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform.scale"];
23 |
24 | scaleAnimation.duration = duration;
25 | scaleAnimation.keyTimes = @[@0.0f, @0.5f, @1.0f];
26 | scaleAnimation.values = @[@1.0f, @0.75f, @1.0f];
27 |
28 | // Opacity animation
29 | CAKeyframeAnimation *opacityAnimation = [CAKeyframeAnimation animationWithKeyPath:@"opacity"];
30 |
31 | opacityAnimation.duration = duration;
32 | opacityAnimation.keyTimes = @[@0.0f, @0.5f, @1.0f];
33 | opacityAnimation.values = @[@1.0f, @0.2f, @1.0f];
34 |
35 | // Aniamtion
36 | CAAnimationGroup *animation = [CAAnimationGroup animation];
37 |
38 | animation.duration = duration;
39 | animation.animations = @[scaleAnimation, opacityAnimation];
40 | animation.repeatCount = HUGE_VALF;
41 | animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
42 |
43 | // Draw circles
44 | for (int i = 0; i < 3; i++) {
45 | CAShapeLayer *circle = [CAShapeLayer layer];
46 | UIBezierPath *circlePath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, circleSize, circleSize) cornerRadius:circleSize / 2];
47 |
48 | animation.beginTime = [beginTimes[i] floatValue];
49 | circle.fillColor = tintColor.CGColor;
50 | circle.path = circlePath.CGPath;
51 | [circle addAnimation:animation forKey:@"animation"];
52 | circle.frame = CGRectMake(x + circleSize * i + circleSpacing * i, y, circleSize, circleSize);
53 | [layer addSublayer:circle];
54 | }
55 | }
56 |
57 | @end
58 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreIV/Lib/DGActivityIndicatorView/Animations/DGActivityIndicatorBallClipRotateAnimation.h:
--------------------------------------------------------------------------------
1 | //
2 | // DGActivityIndicatorBallClipRotateAnimation.h
3 | // DGActivityIndicatorExample
4 | //
5 | // Created by Nguyen Vinh on 7/19/15.
6 | // Copyright (c) 2015 Danil Gontovnik. All rights reserved.
7 | //
8 |
9 | #import "DGActivityIndicatorAnimationProtocol.h"
10 |
11 | @interface DGActivityIndicatorBallClipRotateAnimation : NSObject
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreIV/Lib/DGActivityIndicatorView/Animations/DGActivityIndicatorBallClipRotateAnimation.m:
--------------------------------------------------------------------------------
1 | //
2 | // DGActivityIndicatorBallClipRotateAnimation.m
3 | // DGActivityIndicatorExample
4 | //
5 | // Created by Nguyen Vinh on 7/19/15.
6 | // Copyright (c) 2015 Danil Gontovnik. All rights reserved.
7 | //
8 |
9 | #import "DGActivityIndicatorBallClipRotateAnimation.h"
10 |
11 | @implementation DGActivityIndicatorBallClipRotateAnimation
12 |
13 | - (void)setupAnimationInLayer:(CALayer *)layer withSize:(CGSize)size tintColor:(UIColor *)tintColor {
14 | CGFloat duration = 0.75f;
15 |
16 | // Scale animation
17 | CAKeyframeAnimation *scaleAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform.scale"];
18 |
19 | scaleAnimation.values = @[[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.0f, 1.0f, 1.0f)],
20 | [NSValue valueWithCATransform3D:CATransform3DMakeScale(0.6f, 0.6f, 1.0f)],
21 | [NSValue valueWithCATransform3D:CATransform3DMakeScale(1.0f, 1.0f, 1.0f)]];
22 | scaleAnimation.keyTimes = @[@0.0f, @0.5f, @1.0f];
23 |
24 | // Rotate animation
25 | CAKeyframeAnimation *rotateAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform.rotation.z"];
26 |
27 | rotateAnimation.values = @[@0, @M_PI, @(2 * M_PI)];
28 | rotateAnimation.keyTimes = scaleAnimation.keyTimes;
29 |
30 | // Animation
31 | CAAnimationGroup *animation = [CAAnimationGroup animation];
32 |
33 | animation.animations = @[scaleAnimation, rotateAnimation];
34 | animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
35 | animation.duration = duration;
36 | animation.repeatCount = HUGE_VALF;
37 |
38 | // Draw ball clip
39 | CAShapeLayer *circle = [CAShapeLayer layer];
40 | UIBezierPath *circlePath = [UIBezierPath bezierPathWithArcCenter:CGPointMake(size.width / 2, size.height / 2) radius:size.width / 2 startAngle:1.5 * M_PI endAngle:M_PI clockwise:true];
41 |
42 | circle.path = circlePath.CGPath;
43 | circle.lineWidth = 2;
44 | circle.fillColor = nil;
45 | circle.strokeColor = tintColor.CGColor;
46 |
47 | circle.frame = CGRectMake((layer.bounds.size.width - size.width) / 2, (layer.bounds.size.height - size.height) / 2, size.width, size.height);
48 | [circle addAnimation:animation forKey:@"animation"];
49 | [layer addSublayer:circle];
50 | }
51 |
52 | @end
53 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreIV/Lib/DGActivityIndicatorView/Animations/DGActivityIndicatorBallClipRotateMultipleAnimation.h:
--------------------------------------------------------------------------------
1 | //
2 | // DGActivityIndicatorBallClipRotateMultipleAnimation.h
3 | // DGActivityIndicatorExample
4 | //
5 | // Created by Nguyen Vinh on 7/19/15.
6 | // Copyright (c) 2015 Danil Gontovnik. All rights reserved.
7 | //
8 |
9 | #import "DGActivityIndicatorAnimationProtocol.h"
10 |
11 | @interface DGActivityIndicatorBallClipRotateMultipleAnimation : NSObject
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreIV/Lib/DGActivityIndicatorView/Animations/DGActivityIndicatorBallClipRotateMultipleAnimation.m:
--------------------------------------------------------------------------------
1 | //
2 | // DGActivityIndicatorBallClipRotateMultipleAnimation.m
3 | // DGActivityIndicatorExample
4 | //
5 | // Created by Nguyen Vinh on 7/19/15.
6 | // Copyright (c) 2015 Danil Gontovnik. All rights reserved.
7 | //
8 |
9 | #import "DGActivityIndicatorBallClipRotateMultipleAnimation.h"
10 |
11 | @implementation DGActivityIndicatorBallClipRotateMultipleAnimation
12 |
13 | - (void)setupAnimationInLayer:(CALayer *)layer withSize:(CGSize)size tintColor:(UIColor *)tintColor {
14 | CGFloat bigDuration = 1.0f;
15 | CGFloat smallDuration = bigDuration / 2;
16 | CAMediaTimingFunction *timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
17 |
18 | // Big circle
19 | {
20 | CGFloat circleSize = size.width;
21 | CAShapeLayer *circle = [CAShapeLayer layer];
22 | UIBezierPath *circlePath = [UIBezierPath bezierPath];
23 |
24 | [circlePath addArcWithCenter:CGPointMake(circleSize / 2, circleSize / 2) radius:circleSize / 2 startAngle:-3 * M_PI / 4 endAngle:-M_PI / 4 clockwise:true];
25 | [circlePath moveToPoint:CGPointMake(circleSize / 2 - circleSize / 2 * cosf(M_PI / 4), circleSize / 2 + circleSize / 2 * sinf(M_PI / 4))];
26 | [circlePath addArcWithCenter:CGPointMake(circleSize / 2, circleSize / 2) radius:circleSize / 2 startAngle:-5 * M_PI / 4 endAngle:-7 * M_PI / 4 clockwise:false];
27 | circle.path = circlePath.CGPath;
28 | circle.lineWidth = 2;
29 | circle.fillColor = nil;
30 | circle.strokeColor = tintColor.CGColor;
31 |
32 | circle.frame = CGRectMake((layer.bounds.size.width - circleSize) / 2, (layer.bounds.size.height - circleSize) / 2, circleSize, circleSize);
33 | [circle addAnimation: [self createAnimationInDuration:bigDuration withTimingFunction:timingFunction reverse:false] forKey:@"animation"];
34 | [layer addSublayer:circle];
35 | }
36 |
37 | // Small circle
38 | {
39 | CGFloat circleSize = size.width / 2;
40 | CAShapeLayer *circle = [CAShapeLayer layer];
41 | UIBezierPath *circlePath = [UIBezierPath bezierPath];
42 |
43 | [circlePath addArcWithCenter:CGPointMake(circleSize / 2, circleSize / 2) radius:circleSize / 2 startAngle:3 * M_PI / 4 endAngle:5 * M_PI / 4 clockwise:true];
44 | [circlePath moveToPoint:CGPointMake(circleSize / 2 + circleSize / 2 * cosf(M_PI / 4), circleSize / 2 - circleSize / 2 * sinf(M_PI / 4))];
45 | [circlePath addArcWithCenter:CGPointMake(circleSize / 2, circleSize / 2) radius:circleSize / 2 startAngle:-M_PI / 4 endAngle:M_PI / 4 clockwise:true];
46 | circle.path = circlePath.CGPath;
47 | circle.lineWidth = 2;
48 | circle.fillColor = nil;
49 | circle.strokeColor = tintColor.CGColor;
50 |
51 | circle.frame = CGRectMake((layer.bounds.size.width - circleSize) / 2, (layer.bounds.size.height - circleSize) / 2, circleSize, circleSize);
52 | [circle addAnimation:[self createAnimationInDuration:smallDuration withTimingFunction:timingFunction reverse:true] forKey:@"animation"];
53 | [layer addSublayer:circle];
54 | }
55 | }
56 |
57 | - (CAAnimation *)createAnimationInDuration:(CGFloat) duration withTimingFunction:(CAMediaTimingFunction *) timingFunction reverse:(BOOL) reverse {
58 | // Scale animation
59 | CAKeyframeAnimation *scaleAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform.scale"];
60 |
61 | scaleAnimation.keyTimes = @[@0.0f, @0.5f, @1.0f];
62 | scaleAnimation.values = @[[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.0f, 1.0f, 1.0f)],
63 | [NSValue valueWithCATransform3D:CATransform3DMakeScale(0.6f, 0.6f, 1.0f)],
64 | [NSValue valueWithCATransform3D:CATransform3DMakeScale(1.0f, 1.0f, 1.0f)]];
65 | scaleAnimation.duration = duration;
66 | scaleAnimation.timingFunctions = @[timingFunction, timingFunction];
67 |
68 | // Rotate animation
69 | CAKeyframeAnimation *rotateAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform.rotation.z"];
70 |
71 | if (!reverse) {
72 | rotateAnimation.values = @[@0, @M_PI, @(2 * M_PI)];
73 | } else {
74 | rotateAnimation.values = @[@0, @-M_PI, @(-2 * M_PI)];
75 | }
76 | rotateAnimation.keyTimes = scaleAnimation.keyTimes;
77 | rotateAnimation.duration = duration;
78 | rotateAnimation.timingFunctions = @[timingFunction, timingFunction];
79 |
80 | // Animation
81 | CAAnimationGroup *animation = [CAAnimationGroup animation];
82 |
83 | animation.animations = @[scaleAnimation, rotateAnimation];
84 | animation.repeatCount = HUGE_VALF;
85 | animation.duration = duration;
86 |
87 | return animation;
88 | }
89 |
90 | @end
91 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreIV/Lib/DGActivityIndicatorView/Animations/DGActivityIndicatorBallClipRotatePulseAnimation.h:
--------------------------------------------------------------------------------
1 | //
2 | // DGActivityIndicatorBallClipRotatePulseAnimation.h
3 | // DGActivityIndicatorExample
4 | //
5 | // Created by Nguyen Vinh on 7/19/15.
6 | // Copyright (c) 2015 Danil Gontovnik. All rights reserved.
7 | //
8 |
9 | #import "DGActivityIndicatorAnimationProtocol.h"
10 |
11 | @interface DGActivityIndicatorBallClipRotatePulseAnimation : NSObject
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreIV/Lib/DGActivityIndicatorView/Animations/DGActivityIndicatorBallClipRotatePulseAnimation.m:
--------------------------------------------------------------------------------
1 | //
2 | // DGActivityIndicatorBallClipRotatePulseAnimation.m
3 | // DGActivityIndicatorExample
4 | //
5 | // Created by Nguyen Vinh on 7/19/15.
6 | // Copyright (c) 2015 Danil Gontovnik. All rights reserved.
7 | //
8 |
9 | #import "DGActivityIndicatorBallClipRotatePulseAnimation.h"
10 |
11 | @implementation DGActivityIndicatorBallClipRotatePulseAnimation
12 |
13 | - (void)setupAnimationInLayer:(CALayer *)layer withSize:(CGSize)size tintColor:(UIColor *)tintColor {
14 | CGFloat duration = 1.0f;
15 | CAMediaTimingFunction *timingFunction = [CAMediaTimingFunction functionWithControlPoints:0.09f :0.57f :0.49f :0.9f];
16 |
17 | // Small circle
18 | {
19 | CAKeyframeAnimation *scaleAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform.scale"];
20 |
21 | scaleAnimation.keyTimes = @[@0.0f, @0.3f, @1.0f];
22 | scaleAnimation.values = @[[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.0f, 1.0f, 1.0f)],
23 | [NSValue valueWithCATransform3D:CATransform3DMakeScale(0.3f, 0.3f, 1.0f)],
24 | [NSValue valueWithCATransform3D:CATransform3DMakeScale(1.0f, 1.0f, 1.0f)]];
25 | scaleAnimation.duration = duration;
26 | scaleAnimation.repeatCount = HUGE_VALF;
27 | scaleAnimation.timingFunctions = @[timingFunction, timingFunction];
28 |
29 | CGFloat circleSize = size.width / 2;
30 | CALayer *circle = [CALayer layer];
31 |
32 | circle.frame = CGRectMake((layer.bounds.size.width - circleSize) / 2, (layer.bounds.size.height - circleSize) / 2, circleSize, circleSize);
33 | circle.backgroundColor = tintColor.CGColor;
34 | circle.cornerRadius = circleSize / 2;
35 | [circle addAnimation:scaleAnimation forKey:@"animation"];
36 | [layer addSublayer:circle];
37 | }
38 |
39 | // Big circle
40 | {
41 | // Scale animation
42 | CAKeyframeAnimation *scaleAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform.scale"];
43 |
44 | scaleAnimation.keyTimes = @[@0.0f, @0.5f, @1.0f];
45 | scaleAnimation.values = @[[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.0f, 1.0f, 1.0f)],
46 | [NSValue valueWithCATransform3D:CATransform3DMakeScale(0.6f, 0.6f, 1.0f)],
47 | [NSValue valueWithCATransform3D:CATransform3DMakeScale(1.0f, 1.0f, 1.0f)]];
48 | scaleAnimation.duration = duration;
49 | scaleAnimation.timingFunctions = @[timingFunction, timingFunction];
50 |
51 | // Rotate animation
52 | CAKeyframeAnimation *rotateAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform.rotation.z"];
53 |
54 | rotateAnimation.values = @[@0, @M_PI, @(2 * M_PI)];
55 | rotateAnimation.keyTimes = scaleAnimation.keyTimes;
56 | rotateAnimation.duration = duration;
57 | rotateAnimation.timingFunctions = @[timingFunction, timingFunction];
58 |
59 | // Animation
60 | CAAnimationGroup *animation = [CAAnimationGroup animation];
61 |
62 | animation.animations = @[scaleAnimation, rotateAnimation];
63 | animation.duration = duration;
64 | animation.repeatCount = HUGE_VALF;
65 |
66 | // Draw big circle
67 | CGFloat circleSize = size.width;
68 | CAShapeLayer *circle = [CAShapeLayer layer];
69 | UIBezierPath *circlePath = [UIBezierPath bezierPath];
70 |
71 | [circlePath addArcWithCenter:CGPointMake(circleSize / 2, circleSize / 2) radius:circleSize / 2 startAngle:-3 * M_PI / 4 endAngle:-M_PI / 4 clockwise:true];
72 | [circlePath moveToPoint:CGPointMake(circleSize / 2 - circleSize / 2 * cosf(M_PI / 4), circleSize / 2 + circleSize / 2 * sinf(M_PI / 4))];
73 | [circlePath addArcWithCenter:CGPointMake(circleSize / 2, circleSize / 2) radius:circleSize / 2 startAngle:-5 * M_PI / 4 endAngle:-7 * M_PI / 4 clockwise:false];
74 | circle.path = circlePath.CGPath;
75 | circle.lineWidth = 2;
76 | circle.fillColor = nil;
77 | circle.strokeColor = tintColor.CGColor;
78 |
79 | circle.frame = CGRectMake((layer.bounds.size.width - circleSize) / 2, (layer.bounds.size.height - circleSize) / 2, circleSize, circleSize);
80 | [circle addAnimation:animation forKey:@"animation"];
81 | [layer addSublayer:circle];
82 | }
83 | }
84 |
85 | @end
86 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreIV/Lib/DGActivityIndicatorView/Animations/DGActivityIndicatorBallGridBeatAnimation.h:
--------------------------------------------------------------------------------
1 | //
2 | // DGActivityIndicatorBallGridBeatAnimation.h
3 | // DGActivityIndicatorExample
4 | //
5 | // Created by Nguyen Vinh on 7/20/15.
6 | // Copyright (c) 2015 Danil Gontovnik. All rights reserved.
7 | //
8 |
9 | #import "DGActivityIndicatorAnimationProtocol.h"
10 |
11 | @interface DGActivityIndicatorBallGridBeatAnimation : NSObject
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreIV/Lib/DGActivityIndicatorView/Animations/DGActivityIndicatorBallGridBeatAnimation.m:
--------------------------------------------------------------------------------
1 | //
2 | // DGActivityIndicatorBallGridBeatAnimation.m
3 | // DGActivityIndicatorExample
4 | //
5 | // Created by Nguyen Vinh on 7/20/15.
6 | // Copyright (c) 2015 Danil Gontovnik. All rights reserved.
7 | //
8 |
9 | #import "DGActivityIndicatorBallGridBeatAnimation.h"
10 |
11 | @implementation DGActivityIndicatorBallGridBeatAnimation
12 |
13 | - (void)setupAnimationInLayer:(CALayer *)layer withSize:(CGSize)size tintColor:(UIColor *)tintColor {
14 | NSArray *durations = @[@0.96f, @0.93f, @1.19f, @1.13f, @1.34f, @0.94f, @1.2f, @0.82f, @1.19f];
15 | NSArray *timeOffsets = @[@0.36f, @0.4f, @0.68f, @0.41f, @0.71f, @-0.15f, @-0.12f, @0.01f, @0.32f];
16 | CAMediaTimingFunction *timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault];
17 | CGFloat circleSpacing = 2;
18 | CGFloat circleSize = (size.width - circleSpacing * 2) / 3;
19 | CGFloat x = (layer.bounds.size.width - size.width) / 2;
20 | CGFloat y = (layer.bounds.size.height - size.height) / 2;
21 |
22 | // Animation
23 | CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"opacity"];
24 |
25 | animation.beginTime = CACurrentMediaTime();
26 | animation.keyTimes = @[@0.0f, @0.5f, @1.0f];
27 | animation.values = @[@1.0f, @0.7f, @1.0f];
28 | animation.repeatCount = HUGE_VALF;
29 | animation.timingFunctions = @[timingFunction, timingFunction];
30 |
31 | // Draw circle
32 | for (int i = 0; i < 3; i++) {
33 | for (int j = 0; j < 3; j++) {
34 | CALayer *circle = [self createCirleWith:circleSize color:tintColor];
35 |
36 | animation.duration = [durations[3 * i + j] floatValue];
37 | animation.timeOffset = [timeOffsets[3 * i + j] floatValue];
38 | circle.frame = CGRectMake(x + circleSize * j + circleSpacing * j, y + circleSize * i + circleSpacing * i, circleSize, circleSize);
39 | [circle addAnimation:animation forKey:@"animation"];
40 | [layer addSublayer:circle];
41 | }
42 | }
43 | }
44 |
45 | - (CALayer *)createCirleWith:(CGFloat)size color:(UIColor *)color {
46 | CAShapeLayer *circle = [CAShapeLayer layer];
47 | UIBezierPath *circlePath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, size, size) cornerRadius:size / 2];
48 |
49 | circle.fillColor = color.CGColor;
50 | circle.path = circlePath.CGPath;
51 |
52 | return circle;
53 | }
54 |
55 | @end
56 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreIV/Lib/DGActivityIndicatorView/Animations/DGActivityIndicatorBallGridPulseAnimation.h:
--------------------------------------------------------------------------------
1 | //
2 | // DGActivityIndicatorBallGridPulseAnimation.h
3 | // DGActivityIndicatorExample
4 | //
5 | // Created by Nguyen Vinh on 7/20/15.
6 | // Copyright (c) 2015 Danil Gontovnik. All rights reserved.
7 | //
8 |
9 | #import "DGActivityIndicatorAnimationProtocol.h"
10 |
11 | @interface DGActivityIndicatorBallGridPulseAnimation : NSObject
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreIV/Lib/DGActivityIndicatorView/Animations/DGActivityIndicatorBallGridPulseAnimation.m:
--------------------------------------------------------------------------------
1 | //
2 | // DGActivityIndicatorBallGridPulseAnimation.m
3 | // DGActivityIndicatorExample
4 | //
5 | // Created by Nguyen Vinh on 7/20/15.
6 | // Copyright (c) 2015 Danil Gontovnik. All rights reserved.
7 | //
8 |
9 | #import "DGActivityIndicatorBallGridPulseAnimation.h"
10 |
11 | @implementation DGActivityIndicatorBallGridPulseAnimation
12 |
13 | - (void)setupAnimationInLayer:(CALayer *)layer withSize:(CGSize)size tintColor:(UIColor *)tintColor {
14 | NSArray *durations = @[@0.72f, @1.02f, @1.28f, @1.42f, @1.45f, @1.18f, @0.87f, @1.45f, @1.06f];
15 | NSArray *timeOffsets = @[@-0.06f, @0.25f, @-0.17f, @0.48f, @0.31f, @0.03f, @0.46f, @0.78f, @0.45f];
16 | CAMediaTimingFunction *timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault];
17 | CGFloat circleSpacing = 2;
18 | CGFloat circleSize = (size.width - circleSpacing * 2) / 3;
19 | CGFloat x = (layer.bounds.size.width - size.width) / 2;
20 | CGFloat y = (layer.bounds.size.height - size.height) / 2;
21 |
22 | // Scale animation
23 | CAKeyframeAnimation *scaleAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform.scale"];
24 |
25 | scaleAnimation.keyTimes = @[@0.0f, @0.5f, @1.0f];
26 | scaleAnimation.values = @[@1.0f, @0.5f, @1.0f];
27 | scaleAnimation.timingFunctions = @[timingFunction, timingFunction];
28 |
29 | // Animation
30 | CAKeyframeAnimation *opacityAnimation = [CAKeyframeAnimation animationWithKeyPath:@"opacity"];
31 |
32 | opacityAnimation.keyTimes = @[@0.0f, @0.5f, @1.0f];
33 | opacityAnimation.values = @[@1.0f, @0.7f, @1.0f];
34 | opacityAnimation.timingFunctions = @[timingFunction, timingFunction];
35 |
36 | // Animation
37 | CAAnimationGroup *animation = [CAAnimationGroup animation];
38 |
39 | animation.animations = @[scaleAnimation, opacityAnimation];
40 | animation.beginTime = CACurrentMediaTime();
41 | animation.repeatCount = HUGE_VALF;
42 |
43 | // Draw circle
44 | for (int i = 0; i < 3; i++) {
45 | for (int j = 0; j < 3; j++) {
46 | CALayer *circle = [self createCirleWith:circleSize color:tintColor];
47 |
48 | animation.duration = [durations[3 * i + j] floatValue];
49 | animation.timeOffset = [timeOffsets[3 * i + j] floatValue];
50 | circle.frame = CGRectMake(x + circleSize * j + circleSpacing * j, y + circleSize * i + circleSpacing * i, circleSize, circleSize);
51 | [circle addAnimation:animation forKey:@"animation"];
52 | [layer addSublayer:circle];
53 | }
54 | }
55 | }
56 |
57 | - (CALayer *)createCirleWith:(CGFloat)size color:(UIColor *)color {
58 | CAShapeLayer *circle = [CAShapeLayer layer];
59 | UIBezierPath *circlePath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, size, size) cornerRadius:size / 2];
60 |
61 | circle.fillColor = color.CGColor;
62 | circle.path = circlePath.CGPath;
63 |
64 | return circle;
65 | }
66 |
67 | @end
68 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreIV/Lib/DGActivityIndicatorView/Animations/DGActivityIndicatorBallPulseAnimation.h:
--------------------------------------------------------------------------------
1 | //
2 | // DGActivityIndicatorBallPulseAnimation.h
3 | // DGActivityIndicatorExample
4 | //
5 | // Created by Nguyen Vinh on 7/19/15.
6 | // Copyright (c) 2015 Danil Gontovnik. All rights reserved.
7 | //
8 |
9 | #import "DGActivityIndicatorAnimationProtocol.h"
10 |
11 | @interface DGActivityIndicatorBallPulseAnimation : NSObject
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreIV/Lib/DGActivityIndicatorView/Animations/DGActivityIndicatorBallPulseAnimation.m:
--------------------------------------------------------------------------------
1 | //
2 | // DGActivityIndicatorBallPulseAnimation.m
3 | // DGActivityIndicatorExample
4 | //
5 | // Created by Nguyen Vinh on 7/19/15.
6 | // Copyright (c) 2015 Danil Gontovnik. All rights reserved.
7 | //
8 |
9 | #import "DGActivityIndicatorBallPulseAnimation.h"
10 |
11 | @implementation DGActivityIndicatorBallPulseAnimation
12 |
13 | - (void)setupAnimationInLayer:(CALayer *)layer withSize:(CGSize)size tintColor:(UIColor *)tintColor {
14 | CGFloat circlePadding = 5.0f;
15 | CGFloat circleSize = (size.width - 2 * circlePadding) / 3;
16 | CGFloat x = (layer.bounds.size.width - size.width) / 2;
17 | CGFloat y = (layer.bounds.size.height - circleSize) / 2;
18 | CGFloat duration = 0.75f;
19 | NSArray *timeBegins = @[@0.12f, @0.24f, @0.36f];
20 | CAMediaTimingFunction *timingFunction = [CAMediaTimingFunction functionWithControlPoints:0.2f :0.68f :0.18f :1.08f];
21 |
22 | CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"transform"];
23 |
24 | animation.values = @[[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.0f, 1.0f, 1.0f)],
25 | [NSValue valueWithCATransform3D:CATransform3DMakeScale(0.3f, 0.3f, 1.0f)],
26 | [NSValue valueWithCATransform3D:CATransform3DMakeScale(1.0f, 1.0f, 1.0f)]];
27 | animation.keyTimes = @[@0.0f, @0.3f, @1.0f];
28 | animation.timingFunctions = @[timingFunction, timingFunction];
29 | animation.duration = duration;
30 | animation.repeatCount = HUGE_VALF;
31 |
32 | for (int i = 0; i < 3; i++) {
33 | CALayer *circle = [CALayer layer];
34 |
35 | circle.frame = CGRectMake(x + i * circleSize + i * circlePadding, y, circleSize, circleSize);
36 | circle.backgroundColor = tintColor.CGColor;
37 | circle.cornerRadius = circle.bounds.size.width / 2;
38 | animation.beginTime = [timeBegins[i] floatValue];
39 | [circle addAnimation:animation forKey:@"animation"];
40 | [layer addSublayer:circle];
41 | }
42 | }
43 |
44 | @end
45 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreIV/Lib/DGActivityIndicatorView/Animations/DGActivityIndicatorBallPulseSyncAnimation.h:
--------------------------------------------------------------------------------
1 | //
2 | // DGActivityIndicatorBallPulseSyncAnimation.h
3 | // DGActivityIndicatorExample
4 | //
5 | // Created by Nguyen Vinh on 7/20/15.
6 | // Copyright (c) 2015 Danil Gontovnik. All rights reserved.
7 | //
8 |
9 | #import "DGActivityIndicatorAnimationProtocol.h"
10 |
11 | @interface DGActivityIndicatorBallPulseSyncAnimation : NSObject
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreIV/Lib/DGActivityIndicatorView/Animations/DGActivityIndicatorBallPulseSyncAnimation.m:
--------------------------------------------------------------------------------
1 | //
2 | // DGActivityIndicatorBallPulseSyncAnimation.m
3 | // DGActivityIndicatorExample
4 | //
5 | // Created by Nguyen Vinh on 7/20/15.
6 | // Copyright (c) 2015 Danil Gontovnik. All rights reserved.
7 | //
8 |
9 | #import "DGActivityIndicatorBallPulseSyncAnimation.h"
10 |
11 | @implementation DGActivityIndicatorBallPulseSyncAnimation
12 |
13 | - (void)setupAnimationInLayer:(CALayer *)layer withSize:(CGSize)size tintColor:(UIColor *)tintColor {
14 | CGFloat duration = 0.6f;
15 | NSArray *beginTimes = @[@0.07f, @0.14f, @0.21f];
16 | CGFloat circleSpacing = 2.0f;
17 | CGFloat circleSize = (size.width - circleSpacing * 2) / 3;
18 | CGFloat x = (layer.bounds.size.width - size.width) / 2;
19 | CGFloat y = (layer.bounds.size.height - circleSize) / 2;
20 | CGFloat deltaY = (size.height / 2 - circleSize / 2) / 2;
21 | CAMediaTimingFunction *timingFunciton = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
22 |
23 | // Animation
24 | CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"transform.translation.y"];
25 |
26 | animation.duration = duration;
27 | animation.keyTimes = @[@0.0f, @0.33f, @0.66f, @1.0f];
28 | animation.values = @[@0.0f, @(deltaY), @(-deltaY), @0.0f];
29 | animation.timingFunctions = @[timingFunciton, timingFunciton, timingFunciton];
30 | animation.repeatCount = HUGE_VALF;
31 |
32 | // Draw circles
33 | for (int i = 0; i < 3; i++) {
34 | CAShapeLayer *circle = [CAShapeLayer layer];
35 | UIBezierPath *circlePath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, circleSize, circleSize) cornerRadius:circleSize / 2];
36 |
37 | animation.beginTime = [beginTimes[i] floatValue];
38 | circle.fillColor = tintColor.CGColor;
39 | circle.path = circlePath.CGPath;
40 | [circle addAnimation:animation forKey:@"animation"];
41 | circle.frame = CGRectMake(x + circleSize * i + circleSpacing * i, y, circleSize, circleSize);
42 | [layer addSublayer:circle];
43 | }
44 | }
45 |
46 | @end
47 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreIV/Lib/DGActivityIndicatorView/Animations/DGActivityIndicatorBallRotateAnimation.h:
--------------------------------------------------------------------------------
1 | //
2 | // DGActivityIndicatorBallRotateAnimation.h
3 | // DGActivityIndicatorExample
4 | //
5 | // Created by Nguyen Vinh on 7/20/15.
6 | // Copyright (c) 2015 Danil Gontovnik. All rights reserved.
7 | //
8 |
9 | #import "DGActivityIndicatorAnimationProtocol.h"
10 |
11 | @interface DGActivityIndicatorBallRotateAnimation : NSObject
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreIV/Lib/DGActivityIndicatorView/Animations/DGActivityIndicatorBallRotateAnimation.m:
--------------------------------------------------------------------------------
1 | //
2 | // DGActivityIndicatorBallRotateAnimation.m
3 | // DGActivityIndicatorExample
4 | //
5 | // Created by Nguyen Vinh on 7/20/15.
6 | // Copyright (c) 2015 Danil Gontovnik. All rights reserved.
7 | //
8 |
9 | #import "DGActivityIndicatorBallRotateAnimation.h"
10 |
11 | @implementation DGActivityIndicatorBallRotateAnimation
12 |
13 | - (void)setupAnimationInLayer:(CALayer *)layer withSize:(CGSize)size tintColor:(UIColor *)tintColor {
14 | CGFloat duration = 1.0f;
15 | CGFloat circleSize = size.width / 5;
16 | CAMediaTimingFunction *timingFunction = [CAMediaTimingFunction functionWithControlPoints:0.7f :-0.13f :0.22f :0.86f];
17 |
18 | // Scale animation
19 | CAKeyframeAnimation *scaleAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform.scale"];
20 |
21 | scaleAnimation.keyTimes = @[@0.0f, @0.5f, @1.0f];
22 | scaleAnimation.values = @[[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.0f, 1.0f, 1.0f)],
23 | [NSValue valueWithCATransform3D:CATransform3DMakeScale(0.6f, 0.6f, 1.0f)],
24 | [NSValue valueWithCATransform3D:CATransform3DMakeScale(1.0f, 1.0f, 1.0f)]];
25 | scaleAnimation.duration = duration;
26 | scaleAnimation.timingFunctions = @[timingFunction, timingFunction];
27 |
28 | // Rotate animation
29 | CAKeyframeAnimation *rotateAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform.rotation.z"];
30 |
31 | rotateAnimation.keyTimes = @[@0.0f, @0.5f, @1.0f];
32 | rotateAnimation.values = @[@0, @-M_PI, @(-2 * M_PI)];
33 | rotateAnimation.duration = duration;
34 | rotateAnimation.timingFunctions = @[timingFunction, timingFunction];
35 |
36 | // Animation
37 | CAAnimationGroup *animation = [CAAnimationGroup animation];
38 |
39 | animation.animations = @[scaleAnimation, rotateAnimation];
40 | animation.duration = duration;
41 | animation.repeatCount = HUGE_VALF;
42 |
43 | // Draw circles
44 | CALayer *leftCircle = [CALayer layer];
45 |
46 | leftCircle.backgroundColor = tintColor.CGColor;
47 | leftCircle.opacity = 0.8f;
48 | leftCircle.cornerRadius = circleSize / 2;
49 | leftCircle.frame = CGRectMake(0, (size.height - circleSize) / 2, circleSize, circleSize);
50 |
51 | CALayer *rightCircle = [CALayer layer];
52 |
53 | rightCircle.backgroundColor = tintColor.CGColor;
54 | rightCircle.opacity = 0.8f;
55 | rightCircle.cornerRadius = circleSize / 2;
56 | rightCircle.frame = CGRectMake(size.width - circleSize, (size.height - circleSize) / 2, circleSize, circleSize);
57 |
58 | CALayer *centerCircle = [CALayer layer];
59 |
60 | centerCircle.backgroundColor = tintColor.CGColor;
61 | centerCircle.cornerRadius = circleSize / 2;
62 | centerCircle.frame = CGRectMake((size.width - circleSize) / 2, (size.height - circleSize) / 2, circleSize, circleSize);
63 |
64 | CALayer *circle = [CALayer layer];
65 |
66 | circle.frame = CGRectMake((layer.bounds.size.width - size.width) / 2, (layer.bounds.size.height - size.height) / 2, size.width, size.height);
67 | [circle addSublayer:leftCircle];
68 | [circle addSublayer:rightCircle];
69 | [circle addSublayer:centerCircle];
70 | [circle addAnimation:animation forKey:@"animation"];
71 | [layer addSublayer:circle];
72 | }
73 |
74 | @end
75 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreIV/Lib/DGActivityIndicatorView/Animations/DGActivityIndicatorBallScaleAnimation.h:
--------------------------------------------------------------------------------
1 | //
2 | // DGActivityIndicatorBallScaleAnimation.h
3 | // DGActivityIndicatorExample
4 | //
5 | // Created by Nguyen Vinh on 7/20/15.
6 | // Copyright (c) 2015 Danil Gontovnik. All rights reserved.
7 | //
8 |
9 | #import "DGActivityIndicatorAnimationProtocol.h"
10 |
11 | @interface DGActivityIndicatorBallScaleAnimation : NSObject
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreIV/Lib/DGActivityIndicatorView/Animations/DGActivityIndicatorBallScaleAnimation.m:
--------------------------------------------------------------------------------
1 | //
2 | // DGActivityIndicatorBallScaleAnimation.m
3 | // DGActivityIndicatorExample
4 | //
5 | // Created by Nguyen Vinh on 7/20/15.
6 | // Copyright (c) 2015 Danil Gontovnik. All rights reserved.
7 | //
8 |
9 | #import "DGActivityIndicatorBallScaleAnimation.h"
10 |
11 | @implementation DGActivityIndicatorBallScaleAnimation
12 |
13 | - (void)setupAnimationInLayer:(CALayer *)layer withSize:(CGSize)size tintColor:(UIColor *)tintColor {
14 | CGFloat duration = 1.0f;
15 |
16 | // Scale animation
17 | CABasicAnimation *scaleAnimation = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
18 |
19 | scaleAnimation.duration = duration;
20 | scaleAnimation.fromValue = @0.0f;
21 | scaleAnimation.toValue = @1.0f;
22 |
23 | // Opacity animation
24 | CABasicAnimation *opacityAnimation = [CABasicAnimation animationWithKeyPath:@"opacity"];
25 |
26 | opacityAnimation.duration = duration;
27 | opacityAnimation.fromValue = @1.0f;
28 | opacityAnimation.toValue = @0.0f;
29 |
30 | // Animation
31 | CAAnimationGroup *animation = [CAAnimationGroup animation];
32 |
33 | animation.animations = @[scaleAnimation, opacityAnimation];
34 | animation.duration = duration;
35 | animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
36 | animation.repeatCount = HUGE_VALF;
37 |
38 | // Draw circle
39 | CAShapeLayer *circle = [CAShapeLayer layer];
40 | UIBezierPath *circlePath = [UIBezierPath bezierPathWithRoundedRect: CGRectMake(0, 0, size.width, size.height) cornerRadius:size.width / 2];
41 |
42 | circle.fillColor = tintColor.CGColor;
43 | circle.path = circlePath.CGPath;
44 | [circle addAnimation:animation forKey:@"animation"];
45 | circle.frame = CGRectMake((layer.bounds.size.width - size.width) / 2, (layer.bounds.size.height - size.height) / 2, size.width, size.height);
46 | [layer addSublayer:circle];
47 | }
48 |
49 | @end
50 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreIV/Lib/DGActivityIndicatorView/Animations/DGActivityIndicatorBallScaleMultipleAnimation.h:
--------------------------------------------------------------------------------
1 | //
2 | // DGActivityIndicatorBallScaleMultipleAnimation.h
3 | // DGActivityIndicatorExample
4 | //
5 | // Created by Nguyen Vinh on 7/20/15.
6 | // Copyright (c) 2015 Danil Gontovnik. All rights reserved.
7 | //
8 |
9 | #import "DGActivityIndicatorAnimationProtocol.h"
10 |
11 | @interface DGActivityIndicatorBallScaleMultipleAnimation : NSObject
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreIV/Lib/DGActivityIndicatorView/Animations/DGActivityIndicatorBallScaleMultipleAnimation.m:
--------------------------------------------------------------------------------
1 | //
2 | // DGActivityIndicatorBallScaleMultipleAnimation.m
3 | // DGActivityIndicatorExample
4 | //
5 | // Created by Nguyen Vinh on 7/20/15.
6 | // Copyright (c) 2015 Danil Gontovnik. All rights reserved.
7 | //
8 |
9 | #import "DGActivityIndicatorBallScaleMultipleAnimation.h"
10 |
11 | @implementation DGActivityIndicatorBallScaleMultipleAnimation
12 |
13 | - (void)setupAnimationInLayer:(CALayer *)layer withSize:(CGSize)size tintColor:(UIColor *)tintColor {
14 | CGFloat duration = 1.0f;
15 | NSArray *beginTimes = @[@0.0f, @0.2f, @0.4f];
16 |
17 | // Scale animation
18 | CABasicAnimation *scaleAnimation = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
19 |
20 | scaleAnimation.duration = duration;
21 | scaleAnimation.fromValue = @0.0f;
22 | scaleAnimation.toValue = @1.0f;
23 |
24 | // Opacity animation
25 | CAKeyframeAnimation *opacityAnimation = [CAKeyframeAnimation animationWithKeyPath:@"opacity"];
26 |
27 | opacityAnimation.duration = duration;
28 | opacityAnimation.keyTimes = @[@0.0f, @0.05f, @1.0f];
29 | opacityAnimation.values = @[@0.0f, @1.0f, @0.0f];
30 |
31 | // Animation
32 | CAAnimationGroup *animation = [CAAnimationGroup animation];
33 |
34 | animation.animations = @[scaleAnimation, opacityAnimation];
35 | animation.duration = duration;
36 | animation.repeatCount = HUGE_VALF;
37 | animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
38 |
39 | for (int i = 0; i < 3; i++) {
40 | CAShapeLayer *circle = [CAShapeLayer layer];
41 | UIBezierPath *circlePath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, size.width, size.height) cornerRadius:size.width / 2];
42 |
43 | animation.beginTime = [beginTimes[i] floatValue];
44 | circle.fillColor = tintColor.CGColor;
45 | circle.path = circlePath.CGPath;
46 | circle.opacity = 0.0f;
47 | [circle addAnimation:animation forKey:@"animation"];
48 | circle.frame = CGRectMake((layer.bounds.size.width - size.width) / 2, (layer.bounds.size.height - size.height) / 2, size.width, size.height);
49 | [layer addSublayer:circle];
50 | }
51 | }
52 |
53 | @end
54 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreIV/Lib/DGActivityIndicatorView/Animations/DGActivityIndicatorBallScaleRippleAnimation.h:
--------------------------------------------------------------------------------
1 | //
2 | // DGActivityIndicatorBallScaleTrippleAnimation.h
3 | // DGActivityIndicatorExample
4 | //
5 | // Created by Nguyen Vinh on 7/20/15.
6 | // Copyright (c) 2015 Danil Gontovnik. All rights reserved.
7 | //
8 |
9 | #import "DGActivityIndicatorAnimationProtocol.h"
10 |
11 | @interface DGActivityIndicatorBallScaleRippleAnimation : NSObject
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreIV/Lib/DGActivityIndicatorView/Animations/DGActivityIndicatorBallScaleRippleAnimation.m:
--------------------------------------------------------------------------------
1 | //
2 | // DGActivityIndicatorBallScaleTrippleAnimation.m
3 | // DGActivityIndicatorExample
4 | //
5 | // Created by Nguyen Vinh on 7/20/15.
6 | // Copyright (c) 2015 Danil Gontovnik. All rights reserved.
7 | //
8 |
9 | #import "DGActivityIndicatorBallScaleRippleAnimation.h"
10 |
11 | @implementation DGActivityIndicatorBallScaleRippleAnimation
12 |
13 | - (void)setupAnimationInLayer:(CALayer *)layer withSize:(CGSize)size tintColor:(UIColor *)tintColor {
14 | CGFloat duration = 1.0f;
15 | CAMediaTimingFunction *timingFunction = [CAMediaTimingFunction functionWithControlPoints:0.21f :0.53f :0.56f :0.8f];
16 |
17 | // Scale animation
18 | CAKeyframeAnimation *scaleAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform.scale"];
19 |
20 | scaleAnimation.duration = duration;
21 | scaleAnimation.keyTimes = @[@0.0f, @0.7f];
22 | scaleAnimation.values = @[@0.1f, @1.0f];
23 | scaleAnimation.timingFunction = timingFunction;
24 |
25 | // Opacity animation
26 | CAKeyframeAnimation *opacityAnimation = [CAKeyframeAnimation animationWithKeyPath:@"opacity"];
27 |
28 | opacityAnimation.duration = duration;
29 | opacityAnimation.keyTimes = @[@0.0f, @0.7f, @1.0f];
30 | opacityAnimation.values = @[@1.0f, @0.7f, @0.0f];
31 | opacityAnimation.timingFunctions = @[timingFunction, timingFunction];
32 |
33 | // Animation
34 | CAAnimationGroup *animation = [CAAnimationGroup animation];
35 |
36 | animation.animations = @[scaleAnimation, opacityAnimation];
37 | animation.duration = duration;
38 | animation.repeatCount = HUGE_VALF;
39 |
40 | // Draw circle
41 | CAShapeLayer *circle = [CAShapeLayer layer];
42 | UIBezierPath *circlePath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, size.width, size.height) cornerRadius:size.width / 2];
43 |
44 | circle.fillColor = nil;
45 | circle.lineWidth = 2;
46 | circle.strokeColor = tintColor.CGColor;
47 | circle.path = circlePath.CGPath;
48 | [circle addAnimation:animation forKey:@"animation"];
49 | circle.frame = CGRectMake((layer.bounds.size.width - size.width) / 2, (layer.bounds.size.height - size.height) / 2, size.width, size.height);
50 | [layer addSublayer:circle];
51 | }
52 |
53 | @end
54 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreIV/Lib/DGActivityIndicatorView/Animations/DGActivityIndicatorBallScaleRippleMultipleAnimation.h:
--------------------------------------------------------------------------------
1 | //
2 | // DGActivityIndicatorBallScaleRippleMultipleAnimation.h
3 | // DGActivityIndicatorExample
4 | //
5 | // Created by Nguyen Vinh on 7/20/15.
6 | // Copyright (c) 2015 Danil Gontovnik. All rights reserved.
7 | //
8 |
9 | #import "DGActivityIndicatorAnimationProtocol.h"
10 |
11 | @interface DGActivityIndicatorBallScaleRippleMultipleAnimation : NSObject
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreIV/Lib/DGActivityIndicatorView/Animations/DGActivityIndicatorBallScaleRippleMultipleAnimation.m:
--------------------------------------------------------------------------------
1 | //
2 | // DGActivityIndicatorBallScaleRippleMultipleAnimation.m
3 | // DGActivityIndicatorExample
4 | //
5 | // Created by Nguyen Vinh on 7/20/15.
6 | // Copyright (c) 2015 Danil Gontovnik. All rights reserved.
7 | //
8 |
9 | #import "DGActivityIndicatorBallScaleRippleMultipleAnimation.h"
10 |
11 | @implementation DGActivityIndicatorBallScaleRippleMultipleAnimation
12 |
13 | - (void)setupAnimationInLayer:(CALayer *)layer withSize:(CGSize)size tintColor:(UIColor *)tintColor {
14 | CGFloat duration = 1.25f;
15 | CAMediaTimingFunction *timingFunction = [CAMediaTimingFunction functionWithControlPoints:0.21f :0.53f :0.56f :0.8f];
16 | NSArray *timeOffsets = @[@0.0f, @0.2f, @0.4f];
17 |
18 | // Scale animation
19 | CAKeyframeAnimation *scaleAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform.scale"];
20 |
21 | scaleAnimation.duration = duration;
22 | scaleAnimation.keyTimes = @[@0.0f, @0.7f];
23 | scaleAnimation.values = @[@0.1f, @1.0f];
24 | scaleAnimation.timingFunction = timingFunction;
25 |
26 | // Opacity animation
27 | CAKeyframeAnimation *opacityAnimation = [CAKeyframeAnimation animationWithKeyPath:@"opacity"];
28 |
29 | opacityAnimation.duration = duration;
30 | opacityAnimation.keyTimes = @[@0.0f, @0.7f, @1.0f];
31 | opacityAnimation.values = @[@1.0f, @0.7f, @0.0f];
32 | opacityAnimation.timingFunctions = @[timingFunction, timingFunction];
33 |
34 | // Animation
35 | CAAnimationGroup *animation = [CAAnimationGroup animation];
36 |
37 | animation.animations = @[scaleAnimation, opacityAnimation];
38 | animation.duration = duration;
39 | animation.repeatCount = HUGE_VALF;
40 | animation.beginTime = CACurrentMediaTime();
41 |
42 | // Draw circles
43 | for (int i = 0; i < 3; i++) {
44 | CAShapeLayer *circle = [CAShapeLayer layer];
45 | UIBezierPath *circlePath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, size.width, size.height) cornerRadius:size.width / 2];
46 |
47 | animation.timeOffset = [timeOffsets[i] floatValue];
48 | circle.fillColor = nil;
49 | circle.lineWidth = 2;
50 | circle.strokeColor = tintColor.CGColor;
51 | circle.path = circlePath.CGPath;
52 | [circle addAnimation:animation forKey:@"animation"];
53 | circle.frame = CGRectMake((layer.bounds.size.width - size.width) / 2, (layer.bounds.size.height - size.height) / 2, size.width, size.height);
54 | [layer addSublayer:circle];
55 | }
56 | }
57 |
58 | @end
59 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreIV/Lib/DGActivityIndicatorView/Animations/DGActivityIndicatorBallSpinFadeLoader.h:
--------------------------------------------------------------------------------
1 | //
2 | // DGActivityIndicatorBallSpinFadeLoader.h
3 | // CheeseDigest
4 | //
5 | // Created by Robin.Chao on 9/8/15.
6 | // Copyright (c) 2015 mRocker. All rights reserved.
7 | //
8 |
9 | #import "DGActivityIndicatorAnimationProtocol.h"
10 |
11 | @interface DGActivityIndicatorBallSpinFadeLoader : NSObject
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreIV/Lib/DGActivityIndicatorView/Animations/DGActivityIndicatorBallSpinFadeLoader.m:
--------------------------------------------------------------------------------
1 | //
2 | // DGActivityIndicatorBallSpinFadeLoader.m
3 | // CheeseDigest
4 | //
5 | // Created by Robin.Chao on 9/8/15.
6 | // Copyright (c) 2015 mRocker. All rights reserved.
7 | //
8 |
9 | #import "DGActivityIndicatorBallSpinFadeLoader.h"
10 |
11 | @implementation DGActivityIndicatorBallSpinFadeLoader
12 |
13 |
14 | #pragma mark -
15 | #pragma mark DGActivityIndicatorAnimation Protocol
16 |
17 | - (void)setupAnimationInLayer:(CALayer *)layer withSize:(CGSize)size tintColor:(UIColor *)tintColor {
18 |
19 | CGFloat circleSpacing = -2;
20 | CGFloat circleSize = (size.width - 4 * circleSpacing) / 5;
21 | CGFloat x = (layer.bounds.size.width - size.width) / 2;
22 | CGFloat y = (layer.bounds.size.height - size.height) / 2;
23 |
24 | CFTimeInterval duration = 1;
25 | NSTimeInterval beginTime = CACurrentMediaTime();
26 |
27 | NSArray *beginTimes = @[@0, @0.12, @0.24, @0.36, @0.48, @0.6, @0.72, @0.84];
28 |
29 | CAKeyframeAnimation *scaleAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform.scale"];
30 |
31 | scaleAnimation.keyTimes = @[@0, @0.5, @1];
32 | scaleAnimation.values = @[@1, @0.4, @1];
33 | scaleAnimation.duration = duration;
34 |
35 |
36 | CAKeyframeAnimation *opacityAnimaton = [CAKeyframeAnimation animationWithKeyPath:@"opacity"];
37 |
38 |
39 | opacityAnimaton.keyTimes = @[@0, @0.5, @1];
40 | opacityAnimaton.values = @[@1, @0.3, @1];
41 | opacityAnimaton.duration = duration;
42 |
43 |
44 |
45 |
46 | CAAnimationGroup *animationGroup = [CAAnimationGroup animation];
47 | animationGroup.animations = @[scaleAnimation, opacityAnimaton];
48 | animationGroup.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
49 | animationGroup.duration = duration;
50 | animationGroup.repeatCount = HUGE;
51 | animationGroup.removedOnCompletion = NO;
52 |
53 |
54 | for (int i = 0; i < 8; i++) {
55 | CALayer *circle = [self circleLayer:(M_PI_4 * i) size:circleSize origin:CGPointMake(x, y) containerSize:size color:tintColor];
56 | animationGroup.beginTime = beginTime + [beginTimes[i] doubleValue];
57 |
58 | [layer addSublayer:circle];
59 | [circle addAnimation:animationGroup forKey:@"animation"];
60 | }
61 |
62 | }
63 |
64 |
65 | - (CALayer *)circleLayer:(CGFloat)angle size:(CGFloat)size origin:(CGPoint)origin containerSize:(CGSize)containerSize color:(UIColor *)color{
66 | CGFloat radius = containerSize.width/2;
67 | CALayer *circle = [self createLayerWith:CGSizeMake(size, size) color:color];
68 | CGRect frame = CGRectMake((origin.x + radius * (cos(angle) + 1) - size / 2), origin.y + radius * (sin(angle) + 1) - size / 2, size, size);
69 | circle.frame = frame;
70 |
71 | return circle;
72 | }
73 |
74 | - (CALayer *)createLayerWith:(CGSize)size color:(UIColor *)color{
75 | CAShapeLayer *layer = [CAShapeLayer layer];
76 | UIBezierPath *path = [UIBezierPath bezierPath];
77 |
78 | [path addArcWithCenter:CGPointMake(size.width / 2,size.height / 2) radius:(size.width / 2) startAngle:0 endAngle:2 * M_PI clockwise:NO];
79 | layer.fillColor = color.CGColor;
80 | layer.backgroundColor = nil;
81 | layer.path = path.CGPath;
82 |
83 | return layer;
84 | }
85 |
86 | @end
87 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreIV/Lib/DGActivityIndicatorView/Animations/DGActivityIndicatorBallTrianglePathAnimation.h:
--------------------------------------------------------------------------------
1 | //
2 | // DGActivityIndicatorBallTrianglePathAnimation.h
3 | // DGActivityIndicatorExample
4 | //
5 | // Created by Nguyen Vinh on 7/20/15.
6 | // Copyright (c) 2015 Danil Gontovnik. All rights reserved.
7 | //
8 |
9 | #import "DGActivityIndicatorAnimationProtocol.h"
10 |
11 | @interface DGActivityIndicatorBallTrianglePathAnimation : NSObject
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreIV/Lib/DGActivityIndicatorView/Animations/DGActivityIndicatorBallTrianglePathAnimation.m:
--------------------------------------------------------------------------------
1 | //
2 | // DGActivityIndicatorBallTrianglePathAnimation.m
3 | // DGActivityIndicatorExample
4 | //
5 | // Created by Nguyen Vinh on 7/20/15.
6 | // Copyright (c) 2015 Danil Gontovnik. All rights reserved.
7 | //
8 |
9 | #import "DGActivityIndicatorBallTrianglePathAnimation.h"
10 |
11 | @implementation DGActivityIndicatorBallTrianglePathAnimation
12 |
13 | - (void)setupAnimationInLayer:(CALayer *)layer withSize:(CGSize)size tintColor:(UIColor *)tintColor {
14 | CGFloat duration = 2.0f;
15 | CGFloat circleSize = size.width / 5;
16 | CGFloat deltaX = size.width / 2 - circleSize / 2;
17 | CGFloat deltaY = size.height / 2 - circleSize / 2;
18 | CGFloat x = (layer.bounds.size.width - size.width) / 2;
19 | CGFloat y = (layer.bounds.size.height - size.height) / 2;
20 | CAMediaTimingFunction *timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
21 |
22 | // Animation
23 | CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"transform"];
24 |
25 | animation.keyTimes = @[@0.0f, @0.33f, @0.66f, @1.0f];
26 | animation.duration = duration;
27 | animation.timingFunctions = @[timingFunction, timingFunction, timingFunction];
28 | animation.repeatCount = HUGE_VALF;
29 |
30 | // Top-center circle
31 | CALayer *topCenterCircle = [self createCircleWithSize:circleSize color:tintColor];
32 |
33 | [self changeAnimation:animation values:@[@"{0,0}", @"{hx,fy}", @"{-hx,fy}", @"{0,0}"] deltaX:deltaX deltaY:deltaY];
34 | topCenterCircle.frame = CGRectMake(x + size.width / 2 - circleSize / 2, y, circleSize, circleSize);
35 | [topCenterCircle addAnimation:animation forKey:@"animation"];
36 | [layer addSublayer:topCenterCircle];
37 |
38 | // Bottom-left circle
39 | CALayer *bottomLeftCircle = [self createCircleWithSize:circleSize color:tintColor];
40 |
41 | [self changeAnimation:animation values:@[@"{0,0}", @"{hx,-fy}", @"{fx,0}", @"{0,0}"] deltaX:deltaX deltaY:deltaY];
42 | bottomLeftCircle.frame = CGRectMake(x, y + size.height - circleSize, circleSize, circleSize);
43 | [bottomLeftCircle addAnimation:animation forKey:@"animation"];
44 | [layer addSublayer:bottomLeftCircle];
45 |
46 | // Bottom-right circle
47 | CALayer *bottomRigthCircle = [self createCircleWithSize:circleSize color:tintColor];
48 |
49 | [self changeAnimation:animation values:@[@"{0,0}", @"{-fx,0}", @"{-hx,-fy}", @"{0,0}"] deltaX:deltaX deltaY:deltaY];
50 | bottomRigthCircle.frame = CGRectMake(x + size.width - circleSize, y + size.height - circleSize, circleSize, circleSize);
51 | [bottomRigthCircle addAnimation:animation forKey:@"animation"];
52 | [layer addSublayer:bottomRigthCircle];
53 | }
54 |
55 | - (CALayer *)createCircleWithSize:(CGFloat)size color:(UIColor *)color {
56 | CAShapeLayer *circle = [CAShapeLayer layer];
57 | UIBezierPath *circlePath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, size, size) cornerRadius:size / 2];
58 |
59 | circle.fillColor = nil;
60 | circle.strokeColor = color.CGColor;
61 | circle.lineWidth = 1;
62 | circle.path = circlePath.CGPath;
63 |
64 | return circle;
65 | }
66 |
67 | - (CAAnimation *)changeAnimation:(CAKeyframeAnimation *)animation values:(NSArray *)rawValues deltaX:(CGFloat)deltaX deltaY:(CGFloat)deltaY {
68 | NSMutableArray *values = [NSMutableArray arrayWithCapacity:5];
69 |
70 | for (NSString *rawValue in rawValues) {
71 | CGPoint point = CGPointFromString([self translate:rawValue withDeltaX:deltaX deltaY:deltaY]);
72 |
73 | [values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeTranslation(point.x, point.y, 0)]];
74 | }
75 | animation.values = values;
76 |
77 | return animation;
78 | }
79 |
80 | - (NSString *)translate:(NSString *)valueString withDeltaX:(CGFloat)deltaX deltaY:(CGFloat)deltaY {
81 | NSMutableString *valueMutableString = [NSMutableString stringWithString:valueString];
82 | CGFloat fullDeltaX = 2 * deltaX;
83 | CGFloat fullDeltaY = 2 * deltaY;
84 | NSRange range;
85 |
86 | range.location = 0;
87 | range.length = valueString.length;
88 |
89 | [valueMutableString replaceOccurrencesOfString:@"hx" withString:[NSString stringWithFormat:@"%f", deltaX] options:NSCaseInsensitiveSearch range:range];
90 | range.length = valueMutableString.length;
91 | [valueMutableString replaceOccurrencesOfString:@"fx" withString:[NSString stringWithFormat:@"%f", fullDeltaX] options:NSCaseInsensitiveSearch range:range];
92 | range.length = valueMutableString.length;
93 | [valueMutableString replaceOccurrencesOfString:@"hy" withString:[NSString stringWithFormat:@"%f", deltaY] options:NSCaseInsensitiveSearch range:range];
94 | range.length = valueMutableString.length;
95 | [valueMutableString replaceOccurrencesOfString:@"fy" withString:[NSString stringWithFormat:@"%f", fullDeltaY] options:NSCaseInsensitiveSearch range:range];
96 |
97 | return valueMutableString;
98 | }
99 |
100 | @end
101 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreIV/Lib/DGActivityIndicatorView/Animations/DGActivityIndicatorBallZigZagAnimation.h:
--------------------------------------------------------------------------------
1 | //
2 | // DGActivityIndicatorBallZigZagAnimation.h
3 | // DGActivityIndicatorExample
4 | //
5 | // Created by Nguyen Vinh on 7/20/15.
6 | // Copyright (c) 2015 Danil Gontovnik. All rights reserved.
7 | //
8 |
9 | #import "DGActivityIndicatorAnimationProtocol.h"
10 |
11 | @interface DGActivityIndicatorBallZigZagAnimation : NSObject
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreIV/Lib/DGActivityIndicatorView/Animations/DGActivityIndicatorBallZigZagAnimation.m:
--------------------------------------------------------------------------------
1 | //
2 | // DGActivityIndicatorBallZigZagAnimation.m
3 | // DGActivityIndicatorExample
4 | //
5 | // Created by Nguyen Vinh on 7/20/15.
6 | // Copyright (c) 2015 Danil Gontovnik. All rights reserved.
7 | //
8 |
9 | #import "DGActivityIndicatorBallZigZagAnimation.h"
10 |
11 | @implementation DGActivityIndicatorBallZigZagAnimation
12 |
13 | - (void)setupAnimationInLayer:(CALayer *)layer withSize:(CGSize)size tintColor:(UIColor *)tintColor {
14 | CGFloat duration = 0.7f;
15 | CGFloat circleSize = size.width / 5;
16 | CGFloat deltaX = size.width / 2 - circleSize / 2;
17 | CGFloat deltaY = size.height / 2 - circleSize / 2;
18 |
19 | // Circle 1 animation
20 | CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"transform"];
21 |
22 | animation.duration = duration;
23 | animation.keyTimes = @[@0.0f, @0.33f, @0.66f, @1.0f];
24 | animation.values = @[[NSValue valueWithCATransform3D:CATransform3DMakeTranslation(0, 0, 0)],
25 | [NSValue valueWithCATransform3D:CATransform3DMakeTranslation(-deltaX, -deltaY, 0)],
26 | [NSValue valueWithCATransform3D:CATransform3DMakeTranslation(deltaX, -deltaY, 0)],
27 | [NSValue valueWithCATransform3D:CATransform3DMakeTranslation(0, 0, 0)]];
28 | animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
29 | animation.repeatCount = HUGE_VALF;
30 |
31 | // Draw circle 1
32 | {
33 | CALayer *circle = [CALayer layer];
34 |
35 | circle.backgroundColor = tintColor.CGColor;
36 | circle.cornerRadius = circleSize / 2;
37 | circle.frame = CGRectMake((layer.bounds.size.width - circleSize) / 2, (layer.bounds.size.height - circleSize) / 2, circleSize, circleSize);
38 | [circle addAnimation:animation forKey:@"animation"];
39 | [layer addSublayer:circle];
40 | }
41 |
42 | // Circle 2 animation
43 | animation.values = @[[NSValue valueWithCATransform3D:CATransform3DMakeTranslation(0, 0, 0)],
44 | [NSValue valueWithCATransform3D:CATransform3DMakeTranslation(deltaX, deltaY, 0)],
45 | [NSValue valueWithCATransform3D:CATransform3DMakeTranslation(-deltaX, deltaY, 0)],
46 | [NSValue valueWithCATransform3D:CATransform3DMakeTranslation(0, 0, 0)]];
47 |
48 | // Draw circle 2
49 | {
50 | CALayer *circle = [CALayer layer];
51 |
52 | circle.backgroundColor = tintColor.CGColor;
53 | circle.cornerRadius = circleSize / 2;
54 | circle.frame = CGRectMake((layer.bounds.size.width - circleSize) / 2, (layer.bounds.size.height - circleSize) / 2, circleSize, circleSize);
55 | [circle addAnimation:animation forKey:@"animation"];
56 | [layer addSublayer:circle];
57 | }
58 | }
59 |
60 | @end
61 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreIV/Lib/DGActivityIndicatorView/Animations/DGActivityIndicatorBallZigZagDeflectAnimation.h:
--------------------------------------------------------------------------------
1 | //
2 | // DGActivityIndicatorBallZigZagDeflectAnimation.h
3 | // DGActivityIndicatorExample
4 | //
5 | // Created by Nguyen Vinh on 7/20/15.
6 | // Copyright (c) 2015 Danil Gontovnik. All rights reserved.
7 | //
8 |
9 | #import "DGActivityIndicatorAnimationProtocol.h"
10 |
11 | @interface DGActivityIndicatorBallZigZagDeflectAnimation : NSObject
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreIV/Lib/DGActivityIndicatorView/Animations/DGActivityIndicatorBallZigZagDeflectAnimation.m:
--------------------------------------------------------------------------------
1 | //
2 | // DGActivityIndicatorBallZigZagDeflectAnimation.m
3 | // DGActivityIndicatorExample
4 | //
5 | // Created by Nguyen Vinh on 7/20/15.
6 | // Copyright (c) 2015 Danil Gontovnik. All rights reserved.
7 | //
8 |
9 | #import "DGActivityIndicatorBallZigZagDeflectAnimation.h"
10 |
11 | @implementation DGActivityIndicatorBallZigZagDeflectAnimation
12 |
13 | - (void)setupAnimationInLayer:(CALayer *)layer withSize:(CGSize)size tintColor:(UIColor *)tintColor {
14 | CGFloat duration = 0.75f;
15 | CGFloat circleSize = size.width / 5;
16 | CGFloat deltaX = size.width / 2 - circleSize / 2;
17 | CGFloat deltaY = size.height / 2 - circleSize / 2;
18 |
19 | // Circle 1 animation
20 | CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"transform"];
21 |
22 | animation.duration = duration;
23 | animation.keyTimes = @[@0.0f, @0.33f, @0.66f, @1.0f];
24 | animation.values = @[[NSValue valueWithCATransform3D:CATransform3DMakeTranslation(0, 0, 0)],
25 | [NSValue valueWithCATransform3D:CATransform3DMakeTranslation(-deltaX, -deltaY, 0)],
26 | [NSValue valueWithCATransform3D:CATransform3DMakeTranslation(deltaX, -deltaY, 0)],
27 | [NSValue valueWithCATransform3D:CATransform3DMakeTranslation(0, 0, 0)]];
28 | animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
29 | animation.repeatCount = HUGE_VALF;
30 | animation.autoreverses = true;
31 |
32 | // Draw circle 1
33 | {
34 | CALayer *circle = [CALayer layer];
35 |
36 | circle.backgroundColor = tintColor.CGColor;
37 | circle.cornerRadius = circleSize / 2;
38 | circle.frame = CGRectMake((layer.bounds.size.width - circleSize) / 2, (layer.bounds.size.height - circleSize) / 2, circleSize, circleSize);
39 | [circle addAnimation:animation forKey:@"animation"];
40 | [layer addSublayer:circle];
41 | }
42 |
43 | // Circle 2 animation
44 | animation.values = @[[NSValue valueWithCATransform3D:CATransform3DMakeTranslation(0, 0, 0)],
45 | [NSValue valueWithCATransform3D:CATransform3DMakeTranslation(deltaX, deltaY, 0)],
46 | [NSValue valueWithCATransform3D:CATransform3DMakeTranslation(-deltaX, deltaY, 0)],
47 | [NSValue valueWithCATransform3D:CATransform3DMakeTranslation(0, 0, 0)]];
48 |
49 | // Draw circle 2
50 | {
51 | CALayer *circle = [CALayer layer];
52 |
53 | circle.backgroundColor = tintColor.CGColor;
54 | circle.cornerRadius = circleSize / 2;
55 | circle.frame = CGRectMake((layer.bounds.size.width - circleSize) / 2, (layer.bounds.size.height - circleSize) / 2, circleSize, circleSize);
56 | [circle addAnimation:animation forKey:@"animation"];
57 | [layer addSublayer:circle];
58 | }
59 | }
60 |
61 | @end
62 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreIV/Lib/DGActivityIndicatorView/Animations/DGActivityIndicatorCookieTerminatorAnimation.h:
--------------------------------------------------------------------------------
1 | //
2 | // DGActivityIndicatorCookieTerminatorAnimation.h
3 | // DGActivityIndicatorExample
4 | //
5 | // Created by tripleCC on 15/6/28.
6 | // Copyright (c) 2015年 Danil Gontovnik. All rights reserved.
7 | //
8 |
9 | #import "DGActivityIndicatorAnimationProtocol.h"
10 |
11 | @interface DGActivityIndicatorCookieTerminatorAnimation : NSObject
12 |
13 |
14 | @end
15 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreIV/Lib/DGActivityIndicatorView/Animations/DGActivityIndicatorCookieTerminatorAnimation.m:
--------------------------------------------------------------------------------
1 | //
2 | // DGActivityIndicatorCookieTerminatorAnimation.m
3 | // DGActivityIndicatorExample
4 | //
5 | // Created by tripleCC on 15/6/28.
6 | // Copyright (c) 2015年 Danil Gontovnik. All rights reserved.
7 | //
8 |
9 | #import "DGActivityIndicatorCookieTerminatorAnimation.h"
10 |
11 | @implementation DGActivityIndicatorCookieTerminatorAnimation
12 |
13 | #pragma mark -
14 | #pragma mark DGActivityIndicatorAnimation Protocol
15 |
16 | - (void)setupAnimationInLayer:(CALayer *)layer withSize:(CGSize)size tintColor:(UIColor *)tintColor {
17 | NSTimeInterval beginTime = CACurrentMediaTime();
18 |
19 | CGFloat cookieTerminatorSize = ceilf(size.width / 3.0f);
20 | CGFloat oX = (layer.bounds.size.width - size.width) / 2.0f;
21 | CGFloat oY = layer.bounds.size.height / 2.0f;
22 | CGPoint cookieTerminatorCenter = CGPointMake(oX, oY);
23 |
24 | UIBezierPath *path = [UIBezierPath bezierPathWithArcCenter:cookieTerminatorCenter radius:cookieTerminatorSize startAngle:M_PI_4 endAngle:M_PI * 1.75f clockwise:YES];
25 | [path addLineToPoint:cookieTerminatorCenter];
26 | [path closePath];
27 |
28 | CAShapeLayer *cookieTerminatorLayer = [CAShapeLayer layer];
29 | cookieTerminatorLayer.anchorPoint = CGPointMake(0.5f, 0.5f);
30 | cookieTerminatorLayer.fillColor = tintColor.CGColor;
31 | cookieTerminatorLayer.path = path.CGPath;
32 | [layer addSublayer:cookieTerminatorLayer];
33 |
34 | path = [UIBezierPath bezierPathWithArcCenter:CGPointMake(0.0f, 0.0f) radius:cookieTerminatorSize startAngle:M_PI_2 endAngle:M_PI * 1.5f clockwise:YES];
35 | [path closePath];
36 | for (int i = 0; i < 2; i++) {
37 | CAShapeLayer *jawLayer = [CAShapeLayer layer];
38 | jawLayer.path = path.CGPath;
39 | jawLayer.fillColor = tintColor.CGColor;
40 | jawLayer.position = cookieTerminatorCenter;
41 | jawLayer.anchorPoint = CGPointMake(0.5f, 0.5f);
42 | jawLayer.opacity = 1.0f;
43 | jawLayer.transform = CATransform3DMakeRotation((1.0f - 2.0f * i) * M_PI_4, 0.0f, 0.0f, 1.0f);
44 |
45 | CABasicAnimation *transformAnimation = [CABasicAnimation animationWithKeyPath:@"transform"];
46 | transformAnimation.removedOnCompletion = NO;
47 | transformAnimation.beginTime = beginTime;
48 | transformAnimation.duration = 0.3f;
49 | transformAnimation.fromValue = [NSValue valueWithCATransform3D:CATransform3DMakeRotation((1.0f - 2.0f * i) * M_PI_4, 0.0f, 0.0f, 1.0f)];
50 | transformAnimation.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeRotation((1.0f - 2.0f * i) * M_PI_2, 0.0f, 0.0f, 1.0f)];
51 | transformAnimation.autoreverses = YES;
52 | transformAnimation.repeatCount = HUGE_VALF;
53 | transformAnimation.timingFunction = [CAMediaTimingFunction functionWithName: kCAMediaTimingFunctionEaseInEaseOut];
54 |
55 | [layer addSublayer:jawLayer];
56 | [jawLayer addAnimation:transformAnimation forKey:@"animation"];
57 | }
58 |
59 | CGFloat cookieSize = ceilf(size.width / 6.0f);
60 | CGFloat cookiePadding = cookieSize * 2.0f;
61 | for (int i = 0; i < 3; i++) {
62 | CALayer *cookieLayer = [CALayer layer];
63 | cookieLayer.frame = CGRectMake(cookieTerminatorCenter.x + (cookieSize + cookiePadding) * 3.0f - cookieTerminatorSize, oY - cookieSize / 2.0f, cookieSize, cookieSize);
64 | cookieLayer.backgroundColor = tintColor.CGColor;
65 | cookieLayer.anchorPoint = CGPointMake(0.5f, 0.5f);
66 | cookieLayer.opacity = 1.0f;
67 | cookieLayer.cornerRadius = cookieSize / 2.0f;
68 |
69 | CABasicAnimation *transformAnimation = [CABasicAnimation animationWithKeyPath:@"transform"];
70 | transformAnimation.duration = 1.8f;
71 | transformAnimation.beginTime = beginTime - (i * transformAnimation.duration / 3.0f);
72 | transformAnimation.fromValue = [NSValue valueWithCATransform3D:CATransform3DMakeTranslation(0.0f, 0.0f, 0.0f)];
73 | transformAnimation.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeTranslation(-3.0f * (cookieSize + cookiePadding), 0.0f, 0.0f)];
74 | transformAnimation.repeatCount = HUGE_VALF;
75 | transformAnimation.removedOnCompletion = NO;
76 | transformAnimation.timingFunction = [CAMediaTimingFunction functionWithName: kCAMediaTimingFunctionLinear];
77 |
78 | [layer addSublayer:cookieLayer];
79 | [cookieLayer addAnimation:transformAnimation forKey:@"animation"];
80 | }
81 | }
82 | @end
83 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreIV/Lib/DGActivityIndicatorView/Animations/DGActivityIndicatorDoubleBounceAnimation.h:
--------------------------------------------------------------------------------
1 | //
2 | // DGActivityIndicatorDoubleBounceAnimation.h
3 | // DGActivityIndicatorExample
4 | //
5 | // Created by Danil Gontovnik on 5/23/15.
6 | // Copyright (c) 2015 Danil Gontovnik. All rights reserved.
7 | //
8 |
9 | #import "DGActivityIndicatorAnimationProtocol.h"
10 |
11 | @interface DGActivityIndicatorDoubleBounceAnimation : NSObject
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreIV/Lib/DGActivityIndicatorView/Animations/DGActivityIndicatorDoubleBounceAnimation.m:
--------------------------------------------------------------------------------
1 | //
2 | // DGActivityIndicatorDoubleBounceAnimation.m
3 | // DGActivityIndicatorExample
4 | //
5 | // Created by Danil Gontovnik on 5/23/15.
6 | // Copyright (c) 2015 Danil Gontovnik. All rights reserved.
7 | //
8 |
9 | #import "DGActivityIndicatorDoubleBounceAnimation.h"
10 |
11 | @implementation DGActivityIndicatorDoubleBounceAnimation
12 |
13 | #pragma mark -
14 | #pragma mark DGActivityIndicatorAnimation Protocol
15 |
16 | - (void)setupAnimationInLayer:(CALayer *)layer withSize:(CGSize)size tintColor:(UIColor *)tintColor {
17 | NSTimeInterval beginTime = CACurrentMediaTime();
18 |
19 | CGFloat oX = (layer.bounds.size.width - size.width) / 2.0f;
20 | CGFloat oY = (layer.bounds.size.height - size.height) / 2.0f;
21 | for (int i = 0; i < 2; i++) {
22 | CALayer *circle = [CALayer layer];
23 | circle.frame = CGRectMake(oX, oY, size.width, size.height);
24 | circle.anchorPoint = CGPointMake(0.5f, 0.5f);
25 | circle.opacity = 0.5f;
26 | circle.cornerRadius = size.height / 2.0f;
27 | circle.transform = CATransform3DMakeScale(0.0f, 0.0f, 0.0f);
28 | circle.backgroundColor = tintColor.CGColor;
29 |
30 | CAKeyframeAnimation *transformAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform"];
31 | transformAnimation.removedOnCompletion = NO;
32 | transformAnimation.repeatCount = HUGE_VALF;
33 | transformAnimation.duration = 2.0f;
34 | transformAnimation.beginTime = beginTime - (1.0f * i);
35 | transformAnimation.keyTimes = @[@(0.0f), @(0.5f), @(1.0f)];
36 |
37 | transformAnimation.timingFunctions = @[[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut],
38 | [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut],
39 | [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
40 |
41 | transformAnimation.values = @[[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.0f, 0.0f, 0.0f)],
42 | [NSValue valueWithCATransform3D:CATransform3DMakeScale(1.0f, 1.0f, 0.0f)],
43 | [NSValue valueWithCATransform3D:CATransform3DMakeScale(0.0f, 0.0f, 0.0f)]];
44 |
45 | [layer addSublayer:circle];
46 | [circle addAnimation:transformAnimation forKey:@"animation"];
47 | }
48 |
49 | }
50 |
51 | @end
52 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreIV/Lib/DGActivityIndicatorView/Animations/DGActivityIndicatorFiveDotsAnimation.h:
--------------------------------------------------------------------------------
1 | //
2 | // DGActivityIndicatorFiveDotsAnimation.h
3 | // DGActivityIndicatorExample
4 | //
5 | // Created by Danil Gontovnik on 5/23/15.
6 | // Copyright (c) 2015 Danil Gontovnik. All rights reserved.
7 | //
8 |
9 | #import "DGActivityIndicatorAnimationProtocol.h"
10 |
11 | @interface DGActivityIndicatorFiveDotsAnimation : NSObject
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreIV/Lib/DGActivityIndicatorView/Animations/DGActivityIndicatorFiveDotsAnimation.m:
--------------------------------------------------------------------------------
1 | //
2 | // DGActivityIndicatorFiveDotsAnimation.m
3 | // DGActivityIndicatorExample
4 | //
5 | // Created by Danil Gontovnik on 5/23/15.
6 | // Copyright (c) 2015 Danil Gontovnik. All rights reserved.
7 | //
8 |
9 | #import "DGActivityIndicatorFiveDotsAnimation.h"
10 |
11 | @implementation DGActivityIndicatorFiveDotsAnimation
12 |
13 | #pragma mark -
14 | #pragma mark DGActivityIndicatorAnimation Protocol
15 |
16 | - (void)setupAnimationInLayer:(CALayer *)layer withSize:(CGSize)size tintColor:(UIColor *)tintColor {
17 | NSTimeInterval beginTime = CACurrentMediaTime();
18 |
19 | CGFloat circleSize = size.width / 5.0f;
20 |
21 | CGFloat oX = (layer.bounds.size.width - circleSize * 5) / 2.0f;
22 | CGFloat oY = (layer.bounds.size.height - circleSize) / 2.0f;
23 | for (int i = 0; i < 3; i++) {
24 | CALayer *circle = [CALayer layer];
25 | circle.frame = CGRectMake(oX + circleSize * 2 * i, oY, circleSize, circleSize);
26 | circle.backgroundColor = tintColor.CGColor;
27 | circle.anchorPoint = CGPointMake(0.5f, 0.5f);
28 | circle.opacity = 1.0f;
29 | circle.cornerRadius = circle.bounds.size.height / 2.0f;
30 |
31 | CATransform3D t1 = CATransform3DMakeTranslation(0.0f, 0.0f, 0.0f);
32 | t1 = CATransform3DScale(t1, 1.0f, 1.0f, 0.0f);
33 |
34 | CATransform3D t2 = CATransform3DMakeTranslation(0.0f, -2 * circleSize, 0.0f);
35 | t2 = CATransform3DScale(t2, 1.0f, 1.0f, 0.0f);
36 |
37 | CATransform3D t3 = CATransform3DMakeTranslation(0.0f, 0.0f, 0.0f);
38 | t3 = CATransform3DScale(t3, 0.3f, 0.3f, 0.0f);
39 |
40 | CATransform3D t4 = CATransform3DMakeTranslation(0.0f, 2 * circleSize, 0.0f);
41 | t4 = CATransform3DScale(t4, 1.0f, 1.0f, 0.0f);
42 |
43 | CATransform3D t5 = CATransform3DMakeTranslation(0.0f, 0.0f, 0.0f);
44 | t5 = CATransform3DScale(t5, 1.f, 1.0f, 0.0f);
45 |
46 | CAKeyframeAnimation *transformAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform"];
47 | transformAnimation.values = @[[NSValue valueWithCATransform3D:t1],
48 | [NSValue valueWithCATransform3D:t2],
49 | [NSValue valueWithCATransform3D:t3],
50 | [NSValue valueWithCATransform3D:t4],
51 | [NSValue valueWithCATransform3D:t5]];
52 | transformAnimation.removedOnCompletion = NO;
53 | transformAnimation.beginTime = beginTime;
54 | transformAnimation.repeatCount = HUGE_VALF;
55 | transformAnimation.duration = 1.0f;
56 | transformAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
57 |
58 | [layer addSublayer:circle];
59 | [circle addAnimation:transformAnimation forKey:@"animation"];
60 | }
61 |
62 | for (int i = 0; i < 2; i++) {
63 | CALayer *circle = [CALayer layer];
64 | circle.frame = CGRectMake((layer.bounds.size.width - circleSize * 5) / 2.0f + circleSize + circleSize * 2 * i, (layer.bounds.size.height - circleSize) / 2.0f, circleSize, circleSize);
65 | circle.backgroundColor = tintColor.CGColor;
66 | circle.anchorPoint = CGPointMake(0.5f, 0.5f);
67 | circle.opacity = 1.0f;
68 | circle.cornerRadius = circle.bounds.size.height / 2.0f;
69 |
70 | CATransform3D t1 = CATransform3DMakeTranslation(0.0f, 0.0f, 0.0f);
71 | t1 = CATransform3DScale(t1, 0.3f, 0.3f, 0.0f);
72 |
73 | CATransform3D t2 = CATransform3DMakeTranslation(0.0f, 2 * circleSize, 0.0f);
74 | t2 = CATransform3DScale(t2, 1.0f, 1.0f, 0.0f);
75 |
76 | CATransform3D t3 = CATransform3DMakeTranslation(0.0f, -2 * circleSize, 0.0f);
77 | t3 = CATransform3DScale(t3, 1.f, 1.0f, 0.0f);
78 |
79 | CATransform3D t4 = CATransform3DMakeTranslation(0.0f, 0.0f, 0.0f);
80 | t4 = CATransform3DScale(t4, 0.3f, 0.3f, 0.0f);
81 |
82 | CAKeyframeAnimation *transformAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform"];
83 | transformAnimation.values = @[[NSValue valueWithCATransform3D:t1],
84 | [NSValue valueWithCATransform3D:t2],
85 | [NSValue valueWithCATransform3D:t3],
86 | [NSValue valueWithCATransform3D:t4]];
87 | transformAnimation.keyTimes = @[@(0.0f), @(0.25f), @(0.75f), @(1.0f)];
88 | transformAnimation.removedOnCompletion = NO;
89 | transformAnimation.beginTime = beginTime;
90 | transformAnimation.repeatCount = HUGE_VALF;
91 | transformAnimation.duration = 1.0f;
92 | transformAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
93 |
94 | [layer addSublayer:circle];
95 | [circle addAnimation:transformAnimation forKey:@"animation"];
96 | }
97 | }
98 |
99 | @end
100 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreIV/Lib/DGActivityIndicatorView/Animations/DGActivityIndicatorLineScaleAnimation.h:
--------------------------------------------------------------------------------
1 | //
2 | // DGActivityIndicatorLineScaleAnimation.h
3 | // DGActivityIndicatorExample
4 | //
5 | // Created by Nguyen Vinh on 7/20/15.
6 | // Copyright (c) 2015 Danil Gontovnik. All rights reserved.
7 | //
8 |
9 | #import "DGActivityIndicatorAnimationProtocol.h"
10 |
11 | @interface DGActivityIndicatorLineScaleAnimation : NSObject
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreIV/Lib/DGActivityIndicatorView/Animations/DGActivityIndicatorLineScaleAnimation.m:
--------------------------------------------------------------------------------
1 | //
2 | // DGActivityIndicatorLineScaleAnimation.m
3 | // DGActivityIndicatorExample
4 | //
5 | // Created by Nguyen Vinh on 7/20/15.
6 | // Copyright (c) 2015 Danil Gontovnik. All rights reserved.
7 | //
8 |
9 | #import "DGActivityIndicatorLineScaleAnimation.h"
10 |
11 | @implementation DGActivityIndicatorLineScaleAnimation
12 |
13 | - (void)setupAnimationInLayer:(CALayer *)layer withSize:(CGSize)size tintColor:(UIColor *)tintColor {
14 | CGFloat duration = 1.0f;
15 | NSArray *beginTimes = @[@0.1f, @0.2f, @0.3f, @0.4f, @0.5f];
16 | CAMediaTimingFunction *timingFunction = [CAMediaTimingFunction functionWithControlPoints:0.2f :0.68f :0.18f :1.08f];
17 | CGFloat lineSize = size.width / 9;
18 | CGFloat x = (layer.bounds.size.width - size.width) / 2;
19 | CGFloat y = (layer.bounds.size.height - size.height) / 2;
20 |
21 | // Animation
22 | CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"transform.scale.y"];
23 |
24 | animation.keyTimes = @[@0.0f, @0.5f, @1.0f];
25 | animation.values = @[@1.0f, @0.4f, @1.0f];
26 | animation.timingFunctions = @[timingFunction, timingFunction];
27 | animation.repeatCount = HUGE_VALF;
28 | animation.duration = duration;
29 |
30 | for (int i = 0; i < 5; i++) {
31 | CAShapeLayer *line = [CAShapeLayer layer];
32 | UIBezierPath *linePath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, lineSize, size.height) cornerRadius:lineSize / 2];
33 |
34 | animation.beginTime = [beginTimes[i] floatValue];
35 | line.fillColor = tintColor.CGColor;
36 | line.path = linePath.CGPath;
37 | [line addAnimation:animation forKey:@"animation"];
38 | line.frame = CGRectMake(x + lineSize * 2 * i, y, lineSize, size.height);
39 | [layer addSublayer:line];
40 | }
41 | }
42 |
43 | @end
44 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreIV/Lib/DGActivityIndicatorView/Animations/DGActivityIndicatorLineScalePartyAnimation.h:
--------------------------------------------------------------------------------
1 | //
2 | // DGActivityIndicatorLineScalePartyAnimation.h
3 | // DGActivityIndicatorExample
4 | //
5 | // Created by Nguyen Vinh on 7/20/15.
6 | // Copyright (c) 2015 Danil Gontovnik. All rights reserved.
7 | //
8 |
9 | #import "DGActivityIndicatorAnimationProtocol.h"
10 |
11 | @interface DGActivityIndicatorLineScalePartyAnimation : NSObject
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreIV/Lib/DGActivityIndicatorView/Animations/DGActivityIndicatorLineScalePartyAnimation.m:
--------------------------------------------------------------------------------
1 | //
2 | // DGActivityIndicatorLineScalePartyAnimation.m
3 | // DGActivityIndicatorExample
4 | //
5 | // Created by Nguyen Vinh on 7/20/15.
6 | // Copyright (c) 2015 Danil Gontovnik. All rights reserved.
7 | //
8 |
9 | #import "DGActivityIndicatorLineScalePartyAnimation.h"
10 |
11 | @implementation DGActivityIndicatorLineScalePartyAnimation
12 |
13 | - (void)setupAnimationInLayer:(CALayer *)layer withSize:(CGSize)size tintColor:(UIColor *)tintColor {
14 | NSArray *durations = @[@1.26f, @0.43f, @1.01f, @0.73f];
15 | NSArray *beginTimes = @[@0.77f, @0.29f, @0.28f, @0.74f];
16 | CAMediaTimingFunction *timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault];
17 | CGFloat lineSize = size.width / 7;
18 | CGFloat x = (layer.bounds.size.width - size.width) / 2;
19 | CGFloat y = (layer.bounds.size.height - size.height) / 2;
20 |
21 | // Animation
22 | CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"transform.scale"];
23 |
24 | animation.keyTimes = @[@0.0f, @0.5f, @1.0f];
25 | animation.values = @[@1.0f, @0.5f, @1.0f];
26 | animation.timingFunctions = @[timingFunction, timingFunction];
27 | animation.repeatCount = HUGE_VALF;
28 |
29 | for (int i = 0; i < 4; i++) {
30 | CAShapeLayer *line = [CAShapeLayer layer];
31 | UIBezierPath *linePath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, lineSize, size.height) cornerRadius:lineSize / 2];
32 |
33 | animation.duration = [durations[i] floatValue];
34 | animation.beginTime = [beginTimes[i] floatValue];
35 | line.fillColor = tintColor.CGColor;
36 | line.path = linePath.CGPath;
37 | [line addAnimation:animation forKey:@"animation"];
38 | line.frame = CGRectMake(x + lineSize * 2 * i, y, lineSize, size.height);
39 | [layer addSublayer:line];
40 | }
41 | }
42 |
43 | @end
44 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreIV/Lib/DGActivityIndicatorView/Animations/DGActivityIndicatorLineScalePulseOutAnimation.h:
--------------------------------------------------------------------------------
1 | //
2 | // DGActivityIndicatorLineScalePulseOutAnimation.h
3 | // DGActivityIndicatorExample
4 | //
5 | // Created by Nguyen Vinh on 7/20/15.
6 | // Copyright (c) 2015 Danil Gontovnik. All rights reserved.
7 | //
8 |
9 | #import "DGActivityIndicatorAnimationProtocol.h"
10 |
11 | @interface DGActivityIndicatorLineScalePulseOutAnimation : NSObject
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreIV/Lib/DGActivityIndicatorView/Animations/DGActivityIndicatorLineScalePulseOutAnimation.m:
--------------------------------------------------------------------------------
1 | //
2 | // DGActivityIndicatorLineScalePulseOutAnimation.m
3 | // DGActivityIndicatorExample
4 | //
5 | // Created by Nguyen Vinh on 7/20/15.
6 | // Copyright (c) 2015 Danil Gontovnik. All rights reserved.
7 | //
8 |
9 | #import "DGActivityIndicatorLineScalePulseOutAnimation.h"
10 |
11 | @implementation DGActivityIndicatorLineScalePulseOutAnimation
12 |
13 | - (void)setupAnimationInLayer:(CALayer *)layer withSize:(CGSize)size tintColor:(UIColor *)tintColor {
14 | CGFloat duration = 1.0f;
15 | NSArray *beginTimes = @[@0.4f, @0.2f, @0.0f, @0.2f, @0.4f];
16 | CAMediaTimingFunction *timingFunction = [CAMediaTimingFunction functionWithControlPoints:0.85f :0.25f :0.37f :0.85f];
17 | CGFloat lineSize = size.width / 9;
18 | CGFloat x = (layer.bounds.size.width - size.width) / 2;
19 | CGFloat y = (layer.bounds.size.height - size.height) / 2;
20 |
21 | // Animation
22 | CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"transform.scale.y"];
23 |
24 | animation.keyTimes = @[@0.0f, @0.5f, @1.0f];
25 | animation.values = @[@1.0f, @0.4f, @1.0f];
26 | animation.timingFunctions = @[timingFunction, timingFunction];
27 | animation.repeatCount = HUGE_VALF;
28 | animation.duration = duration;
29 |
30 | for (int i = 0; i < 5; i++) {
31 | CAShapeLayer *line = [CAShapeLayer layer];
32 | UIBezierPath *linePath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, lineSize, size.height) cornerRadius:lineSize / 2];
33 |
34 | animation.beginTime = [beginTimes[i] floatValue];
35 | line.fillColor = tintColor.CGColor;
36 | line.path = linePath.CGPath;
37 | [line addAnimation:animation forKey:@"animation"];
38 | line.frame = CGRectMake(x + lineSize * 2 * i, y, lineSize, size.height);
39 | [layer addSublayer:line];
40 | }
41 | }
42 |
43 | @end
44 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreIV/Lib/DGActivityIndicatorView/Animations/DGActivityIndicatorLineScalePulseOutRapidAnimation.h:
--------------------------------------------------------------------------------
1 | //
2 | // DGActivityIndicatorLineScalePulseOutRapidAnimation.h
3 | // DGActivityIndicatorExample
4 | //
5 | // Created by Nguyen Vinh on 7/20/15.
6 | // Copyright (c) 2015 Danil Gontovnik. All rights reserved.
7 | //
8 |
9 | #import "DGActivityIndicatorAnimationProtocol.h"
10 |
11 | @interface DGActivityIndicatorLineScalePulseOutRapidAnimation : NSObject
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreIV/Lib/DGActivityIndicatorView/Animations/DGActivityIndicatorLineScalePulseOutRapidAnimation.m:
--------------------------------------------------------------------------------
1 | //
2 | // DGActivityIndicatorLineScalePulseOutRapidAnimation.m
3 | // DGActivityIndicatorExample
4 | //
5 | // Created by Nguyen Vinh on 7/20/15.
6 | // Copyright (c) 2015 Danil Gontovnik. All rights reserved.
7 | //
8 |
9 | #import "DGActivityIndicatorLineScalePulseOutRapidAnimation.h"
10 |
11 | @implementation DGActivityIndicatorLineScalePulseOutRapidAnimation
12 |
13 | - (void)setupAnimationInLayer:(CALayer *)layer withSize:(CGSize)size tintColor:(UIColor *)tintColor {
14 | CGFloat duration = 0.9f;
15 | NSArray *beginTimes = @[@0.5f, @0.25f, @0.0f, @0.25f, @0.5f];
16 | CAMediaTimingFunction *timingFunction = [CAMediaTimingFunction functionWithControlPoints:0.11f :0.49f :0.38f :0.78f];
17 | CGFloat lineSize = size.width / 9;
18 | CGFloat x = (layer.bounds.size.width - size.width) / 2;
19 | CGFloat y = (layer.bounds.size.height - size.height) / 2;
20 |
21 | // Animation
22 | CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"transform.scale.y"];
23 |
24 | animation.keyTimes = @[@0.0f, @0.8f, @0.9f];
25 | animation.values = @[@1.0f, @0.3f, @1.0f];
26 | animation.timingFunctions = @[timingFunction, timingFunction];
27 | animation.repeatCount = HUGE_VALF;
28 | animation.duration = duration;
29 |
30 | for (int i = 0; i < 5; i++) {
31 | CAShapeLayer *line = [CAShapeLayer layer];
32 | UIBezierPath *linePath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, lineSize, size.height) cornerRadius:lineSize / 2];
33 |
34 | animation.beginTime = [beginTimes[i] floatValue];
35 | line.fillColor = tintColor.CGColor;
36 | line.path = linePath.CGPath;
37 | [line addAnimation:animation forKey:@"animation"];
38 | line.frame = CGRectMake(x + lineSize * 2 * i, y, lineSize, size.height);
39 | [layer addSublayer:line];
40 | }
41 | }
42 |
43 | @end
44 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreIV/Lib/DGActivityIndicatorView/Animations/DGActivityIndicatorNineDotsAnimation.h:
--------------------------------------------------------------------------------
1 | //
2 | // DGActivityIndicatorNineDotsAnimation.h
3 | // DGActivityIndicatorExample
4 | //
5 | // Created by Danil Gontovnik on 5/23/15.
6 | // Copyright (c) 2015 Danil Gontovnik. All rights reserved.
7 | //
8 |
9 | #import "DGActivityIndicatorAnimationProtocol.h"
10 |
11 | @interface DGActivityIndicatorNineDotsAnimation : NSObject
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreIV/Lib/DGActivityIndicatorView/Animations/DGActivityIndicatorNineDotsAnimation.m:
--------------------------------------------------------------------------------
1 | //
2 | // DGActivityIndicatorNineDotsAnimation.m
3 | // DGActivityIndicatorExample
4 | //
5 | // Created by Danil Gontovnik on 5/23/15.
6 | // Copyright (c) 2015 Danil Gontovnik. All rights reserved.
7 | //
8 |
9 | #import "DGActivityIndicatorNineDotsAnimation.h"
10 |
11 | @implementation DGActivityIndicatorNineDotsAnimation
12 |
13 | #pragma mark -
14 | #pragma mark DGActivityIndicatorAnimation Protocol
15 |
16 | - (void)setupAnimationInLayer:(CALayer *)layer withSize:(CGSize)size tintColor:(UIColor *)tintColor {
17 | NSTimeInterval beginTime = CACurrentMediaTime();
18 |
19 | CGFloat circleSize = size.width / 4.0f;
20 | CGFloat circlePadding = circleSize / 2.0f;
21 |
22 | CGFloat oX = (layer.bounds.size.width - circleSize * 3 - circlePadding * 2) / 2.0f;
23 | CGFloat oY = (layer.bounds.size.height - circleSize * 3 - circlePadding * 2) / 2.0f;
24 |
25 | NSArray *timeOffsets = @[@(0.11f), @(0.42f), @(0.0f),
26 | @(0.65f), @(0.48f), @(0.2f),
27 | @(0.63f), @(0.95f), @(0.62f)];
28 | NSArray *durations = @[@(0.72f), @(1.02f), @(1.28f),
29 | @(1.42f), @(1.45f), @(1.18f),
30 | @(0.87f), @(1.45f), @(1.06f)];
31 |
32 | for (int i = 0; i < MIN(timeOffsets.count, durations.count); i++) {
33 | CALayer *circle = [CALayer layer];
34 | circle.frame = CGRectMake(oX + (circleSize + circlePadding) * (i % 3), oY + (circleSize + circlePadding) * (int)(i / 3), circleSize, circleSize);
35 | circle.backgroundColor = tintColor.CGColor;
36 | circle.anchorPoint = CGPointMake(0.5f, 0.5f);
37 | circle.opacity = 1.0f;
38 | circle.cornerRadius = circle.bounds.size.height / 2.0f;
39 |
40 | CAKeyframeAnimation *transformAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform"];
41 | transformAnimation.values = @[[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.5f, 0.5f, 0.0f)],
42 | [NSValue valueWithCATransform3D:CATransform3DMakeScale(1.0f, 1.0f, 0.0f)],
43 | [NSValue valueWithCATransform3D:CATransform3DMakeScale(0.5f, 0.5f, 0.0f)]];
44 |
45 | CAKeyframeAnimation *opacityAnimation = [CAKeyframeAnimation animationWithKeyPath:@"opacity"];
46 | opacityAnimation.values = @[@(0.5f), @(1.0f), @(0.5f)];
47 |
48 | CAAnimationGroup *animationGroup = [CAAnimationGroup animation];
49 | animationGroup.removedOnCompletion = NO;
50 | animationGroup.beginTime = beginTime;
51 | animationGroup.repeatCount = HUGE_VALF;
52 | animationGroup.duration = [durations[i] doubleValue];
53 | animationGroup.animations = @[transformAnimation, opacityAnimation];
54 | animationGroup.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
55 | animationGroup.timeOffset = [timeOffsets[i] doubleValue];
56 |
57 | [layer addSublayer:circle];
58 | [circle addAnimation:animationGroup forKey:@"animation"];
59 | }
60 | }
61 |
62 | @end
63 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreIV/Lib/DGActivityIndicatorView/Animations/DGActivityIndicatorRotatingSandglassAnimation.h:
--------------------------------------------------------------------------------
1 | //
2 | // DGActivityIndicatorRotatingTrigonsAnimation.h
3 | // DGActivityIndicatorExample
4 | //
5 | // Created by tripleCC on 15/6/26.
6 | // Copyright (c) 2015年 Danil Gontovnik. All rights reserved.
7 | //
8 |
9 | #import "DGActivityIndicatorAnimationProtocol.h"
10 |
11 | @interface DGActivityIndicatorRotatingSandglassAnimation : NSObject
12 |
13 |
14 | @end
15 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreIV/Lib/DGActivityIndicatorView/Animations/DGActivityIndicatorRotatingSandglassAnimation.m:
--------------------------------------------------------------------------------
1 | //
2 | // DGActivityIndicatorRotatingTrigonsAnimation.m
3 | // DGActivityIndicatorExample
4 | //
5 | // Created by tripleCC on 15/6/26.
6 | // Copyright (c) 2015年 Danil Gontovnik. All rights reserved.
7 | //
8 |
9 | #import "DGActivityIndicatorRotatingSandglassAnimation.h"
10 |
11 | @implementation DGActivityIndicatorRotatingSandglassAnimation
12 |
13 | #pragma mark -
14 | #pragma mark DGActivityIndicatorAnimation Protocol
15 |
16 | - (void)setupAnimationInLayer:(CALayer *)layer withSize:(CGSize)size tintColor:(UIColor *)tintColor {
17 |
18 | NSTimeInterval beginTime = CACurrentMediaTime();
19 |
20 | CGFloat circleSize = size.width / 4.0f;;
21 | CGFloat oX = (layer.bounds.size.width - size.width) / 2.0f;
22 | CGFloat oY = (layer.bounds.size.height - size.width) / 2.0f;
23 |
24 | for (int i = 0; i < 2; i++) {
25 | CALayer *circle = [CALayer layer];
26 | circle.frame = CGRectMake(oX + i * (size.width - 2.0f * circleSize), (size.height - circleSize) * i + oY, circleSize, circleSize);
27 | circle.cornerRadius = circle.bounds.size.height / 2.0f;
28 | circle.anchorPoint = CGPointMake(0.5f, 0.5f);
29 | circle.transform = CATransform3DMakeScale(0.0f, 0.0f, 0.0f);
30 | circle.backgroundColor = tintColor.CGColor;
31 | circle.shouldRasterize = YES;
32 | circle.rasterizationScale = [[UIScreen mainScreen] scale];
33 |
34 | CAKeyframeAnimation *transformAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform"];
35 | transformAnimation.removedOnCompletion = NO;
36 | transformAnimation.repeatCount = HUGE_VALF;
37 | transformAnimation.duration = 0.8f;
38 | transformAnimation.beginTime = beginTime;
39 | transformAnimation.keyTimes = @[@(0.0f), @(1.0f / 3.0f), @(2.0f / 3.0f), @(1.0)];
40 |
41 | transformAnimation.timingFunctions = @[[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear],
42 | [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear],
43 | [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear],
44 | [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear]];
45 |
46 | CATransform3D t1 = CATransform3DMakeTranslation((1.0f - 2.0f * i) * (size.width - 2.0f * circleSize), 0.0f, 0.0f);
47 |
48 | CATransform3D t2 = CATransform3DMakeTranslation((1.0f - 2.0f * i) * (size.width - 2.0f * circleSize) / 2.0f, (1.0f - 2.0f * i) * (size.height - circleSize) / 2.0f, 0.0f);
49 |
50 | CATransform3D t3 = CATransform3DMakeTranslation(0.0f, 0.0f, 0.0f);
51 |
52 |
53 | transformAnimation.values = @[[NSValue valueWithCATransform3D:CATransform3DIdentity],
54 | [NSValue valueWithCATransform3D:t1],
55 | [NSValue valueWithCATransform3D:t2],
56 | [NSValue valueWithCATransform3D:t3]];
57 |
58 | [layer addSublayer:circle];
59 | [circle addAnimation:transformAnimation forKey:@"animation"];
60 | }
61 | }
62 | @end
63 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreIV/Lib/DGActivityIndicatorView/Animations/DGActivityIndicatorRotatingSquaresAnimation.h:
--------------------------------------------------------------------------------
1 | //
2 | // DGActivityIndicatorRotatingSquaresAnimation.h
3 | // DGActivityIndicatorExample
4 | //
5 | // Created by Danil Gontovnik on 5/23/15.
6 | // Copyright (c) 2015 Danil Gontovnik. All rights reserved.
7 | //
8 |
9 | #import "DGActivityIndicatorAnimationProtocol.h"
10 |
11 | @interface DGActivityIndicatorRotatingSquaresAnimation : NSObject
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreIV/Lib/DGActivityIndicatorView/Animations/DGActivityIndicatorRotatingSquaresAnimation.m:
--------------------------------------------------------------------------------
1 | //
2 | // DGActivityIndicatorRotatingSquaresAnimation.m
3 | // DGActivityIndicatorExample
4 | //
5 | // Created by Danil Gontovnik on 5/23/15.
6 | // Copyright (c) 2015 Danil Gontovnik. All rights reserved.
7 | //
8 |
9 | #import "DGActivityIndicatorRotatingSquaresAnimation.h"
10 |
11 | static CGFloat degreesToRadians(CGFloat degrees) { return (degrees) / 180.0 * M_PI; };
12 |
13 | @implementation DGActivityIndicatorRotatingSquaresAnimation
14 |
15 | #pragma mark -
16 | #pragma mark DGActivityIndicatorAnimation Protocol
17 |
18 | - (void)setupAnimationInLayer:(CALayer *)layer withSize:(CGSize)size tintColor:(UIColor *)tintColor {
19 | NSTimeInterval beginTime = CACurrentMediaTime();
20 |
21 | CGFloat squareSize = floor(size.width / 4.0f);
22 |
23 | CGFloat oX = (layer.bounds.size.width - size.width) / 2.0f;
24 | CGFloat oY = (layer.bounds.size.height - size.height) / 2.0f;
25 | for (int i = 0; i < 2; i++) {
26 | CALayer *square = [CALayer layer];
27 | square.frame = CGRectMake(oX, oY, squareSize, squareSize);
28 | square.anchorPoint = CGPointMake(0.5f, 0.5f);
29 | square.backgroundColor = tintColor.CGColor;
30 | square.shouldRasterize = YES;
31 | square.rasterizationScale = [[UIScreen mainScreen] scale];
32 |
33 | CAKeyframeAnimation *transformAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform"];
34 | transformAnimation.removedOnCompletion = NO;
35 | transformAnimation.duration = 1.6f;
36 | transformAnimation.beginTime = beginTime - (i * transformAnimation.duration / 2.0f);
37 | transformAnimation.repeatCount = HUGE_VALF;
38 |
39 | transformAnimation.keyTimes = @[@(0.0f), @(0.25f), @(0.50f), @(0.75f), @(1.0f)];
40 | transformAnimation.timingFunctions = @[[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut],
41 | [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut],
42 | [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut],
43 | [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut],
44 | [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
45 |
46 | CATransform3D t1 = CATransform3DMakeTranslation(size.width - squareSize, 0.0f, 0.0f);
47 | t1 = CATransform3DRotate(t1, degreesToRadians(-90.0f), 0.0f, 0.0f, 1.0f);
48 | t1 = CATransform3DScale(t1, 0.5f, 0.5f, 1.0f);
49 |
50 | CATransform3D t2 = CATransform3DMakeTranslation(size.width - squareSize, size.height - squareSize, 0.0f);
51 | t2 = CATransform3DRotate(t2, degreesToRadians(-180.0f), 0.0f, 0.0f, 1.0f);
52 | t2 = CATransform3DScale(t2, 1.0, 1.0, 1.0f);
53 |
54 | CATransform3D t3 = CATransform3DMakeTranslation(0.0f, size.height - squareSize, 0.0f);
55 | t3 = CATransform3DRotate(t3, degreesToRadians(-270.0f), 0.0f, 0.0f, 1.0f);
56 | t3 = CATransform3DScale(t3, 0.5f, 0.5f, 1.0f);
57 |
58 | CATransform3D t4 = CATransform3DMakeTranslation(0.0f, 0.0f, 0.0f);
59 | t4 = CATransform3DRotate(t4, degreesToRadians(-360.0f), 0.0f, 0.0f, 1.0f);
60 | t4 = CATransform3DScale(t4, 1.0, 1.0, 1.0f);
61 |
62 | transformAnimation.values = @[[NSValue valueWithCATransform3D:CATransform3DIdentity],
63 | [NSValue valueWithCATransform3D:t1],
64 | [NSValue valueWithCATransform3D:t2],
65 | [NSValue valueWithCATransform3D:t3],
66 | [NSValue valueWithCATransform3D:t4]];
67 |
68 | [layer addSublayer:square];
69 | [square addAnimation:transformAnimation forKey:@"animation"];
70 | }
71 | }
72 |
73 | @end
74 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreIV/Lib/DGActivityIndicatorView/Animations/DGActivityIndicatorRotatingTrigonAnimation.h:
--------------------------------------------------------------------------------
1 | //
2 | // DGActivityIndicatorRotatingTrigonsAnimation.h
3 | // DGActivityIndicatorExample
4 | //
5 | // Created by tripleCC on 15/6/26.
6 | // Copyright (c) 2015年 Danil Gontovnik. All rights reserved.
7 | //
8 |
9 | #import "DGActivityIndicatorAnimationProtocol.h"
10 |
11 | @interface DGActivityIndicatorRotatingTrigonAnimation : NSObject
12 |
13 |
14 | @end
15 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreIV/Lib/DGActivityIndicatorView/Animations/DGActivityIndicatorRotatingTrigonAnimation.m:
--------------------------------------------------------------------------------
1 | //
2 | // DGActivityIndicatorRotatingTrigonsAnimation.m
3 | // DGActivityIndicatorExample
4 | //
5 | // Created by tripleCC on 15/6/26.
6 | // Copyright (c) 2015年 Danil Gontovnik. All rights reserved.
7 | //
8 |
9 | #import "DGActivityIndicatorRotatingTrigonAnimation.h"
10 |
11 | @implementation DGActivityIndicatorRotatingTrigonAnimation
12 |
13 | #pragma mark -
14 | #pragma mark DGActivityIndicatorAnimation Protocol
15 |
16 | - (void)setupAnimationInLayer:(CALayer *)layer withSize:(CGSize)size tintColor:(UIColor *)tintColor {
17 |
18 | NSTimeInterval beginTime = CACurrentMediaTime();
19 |
20 | CGFloat circleSize = size.width / 4.0f;;
21 | CGFloat oX = (layer.bounds.size.width - size.width) / 2.0f;
22 | CGFloat oY = (layer.bounds.size.height - size.width) / 2.0f;
23 |
24 | UIBezierPath *path = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(0, 0, circleSize, circleSize)];
25 | CGPoint pointA = CGPointMake(oX + size.width / 2.0f, oY + circleSize / 2.0f);
26 | CGPoint pointB = CGPointMake(oX + circleSize / 2.0f, oY + circleSize / 2.0f + sqrtf(powf((size.width - circleSize), 2) - powf((size.width / 2.0f - circleSize / 2.0f), 2)));
27 | CGPoint pointC = CGPointMake(oX + size.width - circleSize / 2.0f, pointB.y);
28 |
29 | for (int i = 0; i < 3; i++) {
30 | CAShapeLayer *circle = [CAShapeLayer layer];
31 | circle.path = path.CGPath;
32 | circle.fillColor = [UIColor clearColor].CGColor;
33 | circle.strokeColor = tintColor.CGColor;
34 | circle.bounds = CGRectMake(0, 0, circleSize, circleSize);
35 | circle.position = pointA;
36 | circle.anchorPoint = CGPointMake(0.5f, 0.5f);
37 | circle.transform = CATransform3DMakeScale(0.0f, 0.0f, 0.0f);
38 | circle.shouldRasterize = YES;
39 | circle.rasterizationScale = [[UIScreen mainScreen] scale];
40 |
41 | CAKeyframeAnimation *transformAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform"];
42 | transformAnimation.removedOnCompletion = NO;
43 | transformAnimation.repeatCount = HUGE_VALF;
44 | transformAnimation.duration = 2.0f;
45 | transformAnimation.beginTime = beginTime - (i * transformAnimation.duration / 3.0f);;
46 | transformAnimation.keyTimes = @[@(0.0f), @(1.0f / 3.0f), @(2.0f / 3.0f), @(1.0)];
47 |
48 | transformAnimation.timingFunctions = @[[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut],
49 | [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut],
50 | [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut],
51 | [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
52 |
53 | CATransform3D t1 = CATransform3DMakeTranslation(pointB.x - pointA.x, pointB.y - pointA.y, 0.0f);
54 |
55 | CATransform3D t2 = CATransform3DMakeTranslation(pointC.x - pointA.x, pointC.y - pointA.y, 0.0f);
56 |
57 | CATransform3D t3 = CATransform3DMakeTranslation(0.0f, 0.0f, 0.0f);
58 |
59 | transformAnimation.values = @[[NSValue valueWithCATransform3D:CATransform3DIdentity],
60 | [NSValue valueWithCATransform3D:t1],
61 | [NSValue valueWithCATransform3D:t2],
62 | [NSValue valueWithCATransform3D:t3]];
63 |
64 | [layer addSublayer:circle];
65 | [circle addAnimation:transformAnimation forKey:@"animation"];
66 | }
67 | }
68 | @end
69 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreIV/Lib/DGActivityIndicatorView/Animations/DGActivityIndicatorThreeDotsAnimation.h:
--------------------------------------------------------------------------------
1 | //
2 | // DGActivityIndicatorThreeDotsAnimation.h
3 | // DGActivityIndicatorExample
4 | //
5 | // Created by Nguyen Vinh on 6/15/15.
6 | // Copyright (c) 2015 Danil Gontovnik. All rights reserved.
7 | //
8 |
9 | #import "DGActivityIndicatorAnimationProtocol.h"
10 |
11 | @interface DGActivityIndicatorThreeDotsAnimation : NSObject
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreIV/Lib/DGActivityIndicatorView/Animations/DGActivityIndicatorThreeDotsAnimation.m:
--------------------------------------------------------------------------------
1 | //
2 | // DGActivityIndicatorThreeDotsAnimation.m
3 | // DGActivityIndicatorExample
4 | //
5 | // Created by Nguyen Vinh on 6/15/15.
6 | // Copyright (c) 2015 Danil Gontovnik. All rights reserved.
7 | //
8 |
9 | #import "DGActivityIndicatorThreeDotsAnimation.h"
10 |
11 | @implementation DGActivityIndicatorThreeDotsAnimation
12 |
13 | #pragma mark -
14 | #pragma mark DGActivityIndicatorAnimation Protocol
15 |
16 | - (void)setupAnimationInLayer:(CALayer *)layer withSize:(CGSize)size tintColor:(UIColor *)tintColor {
17 | NSTimeInterval beginTime = CACurrentMediaTime();
18 | NSTimeInterval duration = 0.5f;
19 |
20 | CGFloat circleSize = size.width / 4.0f;
21 | CGFloat circlePadding = circleSize / 2.0f;
22 |
23 | CGFloat oX = (layer.bounds.size.width - circleSize * 3 - circlePadding * 2) / 2.0f;
24 | CGFloat oY = (layer.bounds.size.height - circleSize * 1) / 2.0f;
25 |
26 | for (int i = 0; i < 3; i++) {
27 | CALayer *circle = [CALayer layer];
28 |
29 | circle.frame = CGRectMake(oX + (circleSize + circlePadding) * (i % 3), oY, circleSize, circleSize);
30 | circle.backgroundColor = tintColor.CGColor;
31 | circle.anchorPoint = CGPointMake(0.5f, 0.5f);
32 | circle.opacity = 1.0f;
33 | circle.cornerRadius = circle.bounds.size.width / 2.0f;
34 |
35 | CAKeyframeAnimation *tranformAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform"];
36 |
37 | tranformAnimation.values = @[[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.5f, 0.5f, 0.0f)],
38 | [NSValue valueWithCATransform3D:CATransform3DMakeScale(1.0f, 1.0f, 0.0f)]];
39 |
40 | CAKeyframeAnimation *opacityAnimation = [CAKeyframeAnimation animationWithKeyPath:@"opacity"];
41 |
42 | opacityAnimation.values = @[@(0.25f), @(1.0f)];
43 |
44 | CAAnimationGroup *animationGroup = [CAAnimationGroup animation];
45 |
46 | animationGroup.removedOnCompletion = NO;
47 | animationGroup.autoreverses = YES;
48 | animationGroup.beginTime = beginTime;
49 | animationGroup.repeatCount = HUGE_VALF;
50 | animationGroup.duration = duration;
51 | animationGroup.animations = @[tranformAnimation, opacityAnimation];
52 | animationGroup.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
53 |
54 | [layer addSublayer:circle];
55 | [circle addAnimation:animationGroup forKey:@"animation"];
56 | }
57 | }
58 |
59 | @end
60 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreIV/Lib/DGActivityIndicatorView/Animations/DGActivityIndicatorTriangleSkewSpinAnimation.h:
--------------------------------------------------------------------------------
1 | //
2 | // DGActivityIndicatorTriangleSkewSpinAnimation.h
3 | // DGActivityIndicatorExample
4 | //
5 | // Created by Nguyen Vinh on 7/20/15.
6 | // Copyright (c) 2015 Danil Gontovnik. All rights reserved.
7 | //
8 |
9 | #import "DGActivityIndicatorAnimationProtocol.h"
10 |
11 | @interface DGActivityIndicatorTriangleSkewSpinAnimation : NSObject
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreIV/Lib/DGActivityIndicatorView/Animations/DGActivityIndicatorTriangleSkewSpinAnimation.m:
--------------------------------------------------------------------------------
1 | //
2 | // DGActivityIndicatorTriangleSkewSpinAnimation.m
3 | // DGActivityIndicatorExample
4 | //
5 | // Created by Nguyen Vinh on 7/20/15.
6 | // Copyright (c) 2015 Danil Gontovnik. All rights reserved.
7 | //
8 |
9 | #import "DGActivityIndicatorTriangleSkewSpinAnimation.h"
10 |
11 | @implementation DGActivityIndicatorTriangleSkewSpinAnimation
12 |
13 | - (void)setupAnimationInLayer:(CALayer *)layer withSize:(CGSize)size tintColor:(UIColor *)tintColor {
14 | CGFloat duration = 3.0f;
15 | CGFloat x = (layer.bounds.size.width - size.width) / 2;
16 | CGFloat y = (layer.bounds.size.height - size.height) / 2;
17 | CAMediaTimingFunction *timingFunction = [CAMediaTimingFunction functionWithControlPoints:0.09f :0.57f :0.49f :0.9f];
18 |
19 | // Rotation x animation
20 | CAKeyframeAnimation *rotationXAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform.rotation.x"];
21 |
22 | rotationXAnimation.duration = duration;
23 | rotationXAnimation.keyTimes = @[@0.0f, @0.25f, @0.5f, @0.75f, @1.0f];
24 | rotationXAnimation.values = @[@0.0f, @M_PI, @M_PI, @0.0f, @0.0f];
25 | rotationXAnimation.timingFunctions = @[timingFunction, timingFunction, timingFunction, timingFunction];
26 |
27 | // Rotation x animation
28 | CAKeyframeAnimation *rotationYAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform.rotation.y"];
29 |
30 | rotationYAnimation.duration = duration;
31 | rotationYAnimation.keyTimes = @[@0.0f, @0.25f, @0.5f, @0.75f, @1.0f];
32 | rotationYAnimation.values = @[@0.0f, @0.0f, @M_PI, @M_PI, @0.0f];
33 | rotationYAnimation.timingFunctions = @[timingFunction, timingFunction, timingFunction, timingFunction];
34 |
35 | // Animation
36 | CAAnimationGroup *animation = [CAAnimationGroup animation];
37 |
38 | animation.animations = @[rotationXAnimation, rotationYAnimation];
39 | animation.duration = duration;
40 | animation.repeatCount = HUGE_VALF;
41 |
42 | // Draw triangle
43 | CAShapeLayer *triangle = [CAShapeLayer layer];
44 | UIBezierPath *trianglePath = [UIBezierPath bezierPath];
45 | CGFloat offsetY = size.height / 4;
46 |
47 | [trianglePath moveToPoint:CGPointMake(0, size.height - offsetY)];
48 | [trianglePath addLineToPoint:CGPointMake(size.width / 2, size.height / 2 - offsetY)];
49 | [trianglePath addLineToPoint:CGPointMake(size.width, size.height - offsetY)];
50 | [trianglePath closePath];
51 | triangle.fillColor = tintColor.CGColor;
52 | triangle.path = trianglePath.CGPath;
53 | [triangle addAnimation:animation forKey:@"animation"];
54 | triangle.frame = CGRectMake(x, y, size.width, size.height);
55 | [layer addSublayer:triangle];
56 | }
57 |
58 | @end
59 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreIV/Lib/DGActivityIndicatorView/Animations/DGActivityIndicatorTriplePulseAnimation.h:
--------------------------------------------------------------------------------
1 | //
2 | // DGActivityIndicatorTriplePulseAnimation.h
3 | // DGActivityIndicatorExample
4 | //
5 | // Created by Danil Gontovnik on 5/23/15.
6 | // Copyright (c) 2015 Danil Gontovnik. All rights reserved.
7 | //
8 |
9 | #import "DGActivityIndicatorAnimationProtocol.h"
10 |
11 | @interface DGActivityIndicatorTriplePulseAnimation : NSObject
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreIV/Lib/DGActivityIndicatorView/Animations/DGActivityIndicatorTriplePulseAnimation.m:
--------------------------------------------------------------------------------
1 | //
2 | // DGActivityIndicatorTriplePulseAnimation.m
3 | // DGActivityIndicatorExample
4 | //
5 | // Created by Danil Gontovnik on 5/23/15.
6 | // Copyright (c) 2015 Danil Gontovnik. All rights reserved.
7 | //
8 |
9 | #import "DGActivityIndicatorTriplePulseAnimation.h"
10 |
11 | @implementation DGActivityIndicatorTriplePulseAnimation
12 |
13 | #pragma mark -
14 | #pragma mark DGActivityIndicatorAnimation Protocol
15 |
16 | - (void)setupAnimationInLayer:(CALayer *)layer withSize:(CGSize)size tintColor:(UIColor *)tintColor {
17 | NSTimeInterval beginTime = CACurrentMediaTime();
18 |
19 | CGFloat oX = (layer.bounds.size.width - size.width) / 2.0f;
20 | CGFloat oY = (layer.bounds.size.height - size.height) / 2.0f;
21 | for (int i = 0; i < 4; i++) {
22 | CALayer *circle = [CALayer layer];
23 | circle.frame = CGRectMake(oX, oY, size.width, size.height);
24 | circle.backgroundColor = tintColor.CGColor;
25 | circle.anchorPoint = CGPointMake(0.5f, 0.5f);
26 | circle.opacity = 0.8f;
27 | circle.cornerRadius = circle.bounds.size.height / 2.0f;
28 | circle.transform = CATransform3DMakeScale(0.0f, 0.0f, 0.0f);
29 |
30 | CABasicAnimation *transformAnimation = [CABasicAnimation animationWithKeyPath:@"transform"];
31 | transformAnimation.fromValue = [NSValue valueWithCATransform3D:CATransform3DMakeScale(0.0f, 0.0f, 0.0f)];
32 | transformAnimation.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeScale(1.0f, 1.0f, 0.0f)];
33 |
34 | CABasicAnimation *opacityAnimation = [CABasicAnimation animationWithKeyPath:@"opacity"];
35 | opacityAnimation.fromValue = @(0.8f);
36 | opacityAnimation.toValue = @(0.0f);
37 |
38 | CAAnimationGroup *animationGroup = [CAAnimationGroup animation];
39 | animationGroup.removedOnCompletion = NO;
40 | animationGroup.beginTime = beginTime + i * 0.2f;
41 | animationGroup.repeatCount = HUGE_VALF;
42 | animationGroup.duration = 1.2f;
43 | animationGroup.animations = @[transformAnimation, opacityAnimation];
44 |
45 | [layer addSublayer:circle];
46 | [circle addAnimation:animationGroup forKey:@"animation"];
47 | }
48 | }
49 |
50 | @end
51 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreIV/Lib/DGActivityIndicatorView/Animations/DGActivityIndicatorTripleRingsAnimation.h:
--------------------------------------------------------------------------------
1 | //
2 | // DGActivityIndicatorTripleRingsPulseAnimation.h
3 | // DGActivityIndicatorExample
4 | //
5 | // Created by tripleCC on 15/6/28.
6 | // Copyright (c) 2015年 Danil Gontovnik. All rights reserved.
7 | //
8 | #import "DGActivityIndicatorAnimationProtocol.h"
9 |
10 | @interface DGActivityIndicatorTripleRingsAnimation : NSObject
11 |
12 | @end
13 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreIV/Lib/DGActivityIndicatorView/Animations/DGActivityIndicatorTripleRingsAnimation.m:
--------------------------------------------------------------------------------
1 | //
2 | // DGActivityIndicatorTripleRingsPulseAnimation.m
3 | // DGActivityIndicatorExample
4 | //
5 | // Created by tripleCC on 15/6/28.
6 | // Copyright (c) 2015年 Danil Gontovnik. All rights reserved.
7 | //
8 |
9 | #import "DGActivityIndicatorTripleRingsAnimation.h"
10 |
11 | @implementation DGActivityIndicatorTripleRingsAnimation
12 |
13 | #pragma mark -
14 | #pragma mark DGActivityIndicatorAnimation Protocol
15 |
16 | - (void)setupAnimationInLayer:(CALayer *)layer withSize:(CGSize)size tintColor:(UIColor *)tintColor {
17 | NSTimeInterval beginTime = CACurrentMediaTime();
18 |
19 | UIBezierPath *path = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(0.0f, 0.0f, size.width, size.width)];
20 | CGFloat oX = (layer.bounds.size.width - size.width) / 2.0f;
21 | CGFloat oY = (layer.bounds.size.height - size.height) / 2.0f;
22 | for (int i = 0; i < 3; i++) {
23 | CAShapeLayer *circle = [CAShapeLayer layer];
24 | circle.path = path.CGPath;
25 | circle.fillColor = [UIColor clearColor].CGColor;
26 | circle.strokeColor = tintColor.CGColor;
27 | circle.frame = CGRectMake(oX, oY, size.width, size.height);
28 | circle.anchorPoint = CGPointMake(0.5f, 0.5f);
29 | circle.opacity = 1.0f;
30 | circle.transform = CATransform3DMakeScale(0.0f, 0.0f, 0.0f);
31 |
32 | CABasicAnimation *transformAnimation = [CABasicAnimation animationWithKeyPath:@"transform"];
33 | transformAnimation.duration = 2.0f - i * 0.4f;
34 | transformAnimation.fromValue = [NSValue valueWithCATransform3D:CATransform3DMakeScale(0.1f, 0.1f, 0.0f)];
35 | transformAnimation.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeScale(1.0f, 1.0f, 0.0f)];
36 | transformAnimation.timingFunction = [CAMediaTimingFunction functionWithName: kCAMediaTimingFunctionEaseOut];
37 |
38 | CABasicAnimation *opacityAnimation = [CABasicAnimation animationWithKeyPath:@"opacity"];
39 | opacityAnimation.duration = transformAnimation.duration;
40 | opacityAnimation.fromValue = @(1.0f);
41 | opacityAnimation.toValue = @(0.8f);
42 | opacityAnimation.timingFunction = [CAMediaTimingFunction functionWithName: kCAMediaTimingFunctionEaseOut];
43 |
44 | CAAnimationGroup *animationGroup = [CAAnimationGroup animation];
45 | animationGroup.removedOnCompletion = NO;
46 | animationGroup.beginTime = beginTime + i * 0.4f;
47 | animationGroup.repeatCount = HUGE_VALF;
48 | animationGroup.duration = 2.0f;
49 | animationGroup.animations = @[transformAnimation, opacityAnimation];
50 |
51 | [layer addSublayer:circle];
52 | [circle addAnimation:animationGroup forKey:@"animation"];
53 | }
54 | }
55 | @end
56 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreIV/Lib/DGActivityIndicatorView/Animations/DGActivityIndicatorTwoDotsAnimation.h:
--------------------------------------------------------------------------------
1 | //
2 | // DGActivityIndicatorTwoDotsAnimation.h
3 | // DGActivityIndicatorExample
4 | //
5 | // Created by Danil Gontovnik on 5/24/15.
6 | // Copyright (c) 2015 Danil Gontovnik. All rights reserved.
7 | //
8 |
9 | #import "DGActivityIndicatorAnimationProtocol.h"
10 |
11 | @interface DGActivityIndicatorTwoDotsAnimation : NSObject
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreIV/Lib/DGActivityIndicatorView/Animations/DGActivityIndicatorTwoDotsAnimation.m:
--------------------------------------------------------------------------------
1 | //
2 | // DGActivityIndicatorTwoDotsAnimation.m
3 | // DGActivityIndicatorExample
4 | //
5 | // Created by Danil Gontovnik on 5/24/15.
6 | // Copyright (c) 2015 Danil Gontovnik. All rights reserved.
7 | //
8 |
9 | #import "DGActivityIndicatorTwoDotsAnimation.h"
10 |
11 | @implementation DGActivityIndicatorTwoDotsAnimation
12 |
13 | - (void)setupAnimationInLayer:(CALayer *)layer withSize:(CGSize)size tintColor:(UIColor *)tintColor {
14 | NSTimeInterval beginTime = CACurrentMediaTime();
15 |
16 | CGFloat circleSize = size.width * 0.92f;
17 | CGFloat oX = (layer.bounds.size.width - size.width) / 2.0f;
18 | CGFloat oY = (layer.bounds.size.height - circleSize) / 2.0f;
19 | for (int i = 0; i < 2; i++) {
20 | CALayer *circle = [CALayer layer];
21 | CGFloat offset = circleSize / 2.0f * i;
22 | circle.frame = CGRectMake((offset + size.width - circleSize) * i + oX, oY, circleSize, circleSize);
23 | circle.cornerRadius = circle.bounds.size.height / 2.0f;
24 | circle.anchorPoint = CGPointMake(0.5f, 0.5f);
25 | circle.transform = CATransform3DMakeScale(0.0f, 0.0f, 0.0f);
26 | circle.backgroundColor = tintColor.CGColor;
27 |
28 | CAKeyframeAnimation *transformAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform"];
29 | transformAnimation.removedOnCompletion = NO;
30 | transformAnimation.repeatCount = HUGE_VALF;
31 | transformAnimation.duration = 1.8f;
32 | transformAnimation.beginTime = beginTime - (transformAnimation.duration / 2.0f * i);
33 | transformAnimation.keyTimes = @[@(0.0), @(0.5), @(1.0)];
34 |
35 | transformAnimation.timingFunctions = @[[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut],
36 | [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut],
37 | [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
38 |
39 | transformAnimation.values = @[[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.0f, 0.0f, 0.0f)],
40 | [NSValue valueWithCATransform3D:CATransform3DMakeScale(1.0f, 1.0f, 0.0f)],
41 | [NSValue valueWithCATransform3D:CATransform3DMakeScale(0.0f, 0.0f, 0.0f)]];
42 |
43 | [layer addSublayer:circle];
44 | [circle addAnimation:transformAnimation forKey:@"animation"];
45 | }
46 | }
47 |
48 | @end
49 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreIV/Lib/DGActivityIndicatorView/DGActivityIndicatorAnimationProtocol.h:
--------------------------------------------------------------------------------
1 | //
2 | // DGActivityIndicatorAnimationProtocol.h
3 | // DGActivityIndicatorExample
4 | //
5 | // Created by Danil Gontovnik on 5/23/15.
6 | // Copyright (c) 2015 Danil Gontovnik. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | @protocol DGActivityIndicatorAnimationProtocol
13 |
14 | - (void)setupAnimationInLayer:(CALayer *)layer withSize:(CGSize)size tintColor:(UIColor *)tintColor;
15 |
16 | @end
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreIV/Lib/DGActivityIndicatorView/DGActivityIndicatorView.h:
--------------------------------------------------------------------------------
1 | //
2 | // DGActivityIndicatorView.h
3 | // DGActivityIndicatorExample
4 | //
5 | // Created by Danil Gontovnik on 5/23/15.
6 | // Copyright (c) 2015 Danil Gontovnik. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | typedef NS_ENUM(NSUInteger, DGActivityIndicatorAnimationType) {
12 | DGActivityIndicatorAnimationTypeNineDots,
13 | DGActivityIndicatorAnimationTypeTriplePulse,
14 | DGActivityIndicatorAnimationTypeFiveDots,
15 | DGActivityIndicatorAnimationTypeRotatingSquares,
16 | DGActivityIndicatorAnimationTypeDoubleBounce,
17 | DGActivityIndicatorAnimationTypeTwoDots,
18 | DGActivityIndicatorAnimationTypeThreeDots,
19 | DGActivityIndicatorAnimationTypeBallPulse,
20 | DGActivityIndicatorAnimationTypeBallClipRotate,
21 | DGActivityIndicatorAnimationTypeBallClipRotatePulse,
22 | DGActivityIndicatorAnimationTypeBallClipRotateMultiple,
23 | DGActivityIndicatorAnimationTypeBallRotate,
24 | DGActivityIndicatorAnimationTypeBallZigZag,
25 | DGActivityIndicatorAnimationTypeBallZigZagDeflect,
26 | DGActivityIndicatorAnimationTypeBallTrianglePath,
27 | DGActivityIndicatorAnimationTypeBallScale,
28 | DGActivityIndicatorAnimationTypeLineScale,
29 | DGActivityIndicatorAnimationTypeLineScaleParty,
30 | DGActivityIndicatorAnimationTypeBallScaleMultiple,
31 | DGActivityIndicatorAnimationTypeBallPulseSync,
32 | DGActivityIndicatorAnimationTypeBallBeat,
33 | DGActivityIndicatorAnimationTypeLineScalePulseOut,
34 | DGActivityIndicatorAnimationTypeLineScalePulseOutRapid,
35 | DGActivityIndicatorAnimationTypeBallScaleRipple,
36 | DGActivityIndicatorAnimationTypeBallScaleRippleMultiple,
37 | DGActivityIndicatorAnimationTypeTriangleSkewSpin,
38 | DGActivityIndicatorAnimationTypeBallGridBeat,
39 | DGActivityIndicatorAnimationTypeBallGridPulse,
40 | DGActivityIndicatorAnimationTypeRotatingSandglass,
41 | DGActivityIndicatorAnimationTypeRotatingTrigons,
42 | DGActivityIndicatorAnimationTypeTripleRings,
43 | DGActivityIndicatorAnimationTypeCookieTerminator,
44 | DGActivityIndicatorAnimationTypeBallSpinFadeLoader
45 | };
46 |
47 | @interface DGActivityIndicatorView : UIView
48 |
49 | - (id)initWithType:(DGActivityIndicatorAnimationType)type;
50 | - (id)initWithType:(DGActivityIndicatorAnimationType)type tintColor:(UIColor *)tintColor;
51 | - (id)initWithType:(DGActivityIndicatorAnimationType)type tintColor:(UIColor *)tintColor size:(CGFloat)size;
52 |
53 | @property (nonatomic) DGActivityIndicatorAnimationType type;
54 | @property (nonatomic, strong) UIColor *tintColor;
55 | @property (nonatomic) CGFloat size;
56 |
57 | @property (nonatomic, readonly) BOOL animating;
58 |
59 | - (void)startAnimating;
60 | - (void)stopAnimating;
61 |
62 | @end
63 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreSVP/CoreSVP+Swift.swift:
--------------------------------------------------------------------------------
1 | ////
2 | //// CoreSVP+Swift.swift
3 | //// CoreSVP
4 | ////
5 | //// Created by 冯成林 on 15/9/18.
6 | //// Copyright (c) 2015年 muxi. All rights reserved.
7 | ////
8 | //
9 | //import Foundation
10 | //
11 | //
12 | ///** 成功 */
13 | //func CoreSVPSuccess(msg: String,completeClosure:(()->())!){
14 | //
15 | // CoreSVP.showSVPWithType(CoreSVPTypeSuccess, msg: msg, duration: 1.6, allowEdit: false, beginBlock: nil) { () -> Void in
16 | // completeClosure?()
17 | // }
18 | //}
19 | //
20 | ///** 失败 */
21 | //func CoreSVPError(msg: String,completeClosure:(()->())!){
22 | //
23 | // CoreSVP.showSVPWithType(CoreSVPTypeError, msg: msg, duration: 2, allowEdit: false, beginBlock: nil) { () -> Void in
24 | // completeClosure?()
25 | // }
26 | //}
27 | //
28 | ///** 注意 */
29 | //func CoreSVPWarning(msg: String,completeClosure:(()->())!){
30 | //
31 | // CoreSVP.showSVPWithType(CoreSVPTypeInfo, msg: msg, duration: 2, allowEdit: false, beginBlock: nil) { () -> Void in
32 | // completeClosure?()
33 | // }
34 | //}
35 | //
36 | //
37 | ///** 底部消息 */
38 | //func CoreSVPBottomMsg(msg: String,completeClosure:(()->())!){
39 | //
40 | // CoreSVP.showSVPWithType(CoreSVPTypeBottomMsg, msg: msg, duration: 1.6, allowEdit: false, beginBlock: nil) { () -> Void in
41 | // completeClosure?()
42 | // }
43 | //}
44 | //
45 | ///** 进度 */
46 | //func CoreSVPLoading(msg: String, url: String){
47 | //
48 | // CoreSVP.showSVPLoadingWithMsg(msg, url: url)
49 | //}
50 | //
51 | //
52 | //
53 | ///** 消失 */
54 | //func CoreSVPDismiss(){ CoreSVP.dismiss() }
55 | //func CoreSVPDismissDelay(delay: NSTimeInterval){CoreSVP.dismiss(delay)}
56 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreSVP/CoreSVP.h:
--------------------------------------------------------------------------------
1 | //
2 | // CoreSVP.h
3 | //
4 | // Created by muxi on 14/10/22.
5 | // Copyright (c) 2014年 muxi. All rights reserved.
6 | // 提示工具类
7 |
8 |
9 |
10 | #import
11 | #import
12 | #import "SVProgressHUD.h"
13 |
14 | #define isNightMode NO
15 |
16 | #define CoreSVPSuccess(msg, CompleteBlock) [CoreSVP showSVPWithType:CoreSVPTypeSuccess Msg:msg duration:1.5 allowEdit:NO beginBlock:nil completeBlock:CompleteBlock];
17 | #define CoreSVPError(msg, CompleteBlock) [CoreSVP showSVPWithType:CoreSVPTypeError Msg:msg duration:2.0 allowEdit:NO beginBlock:nil completeBlock:CompleteBlock];
18 | #define CoreSVPWarning(msg, CompleteBlock) [CoreSVP showSVPWithType:CoreSVPTypeInfo Msg:msg duration:2.0 allowEdit:NO beginBlock:nil completeBlock:CompleteBlock];
19 | #define CoreSVPLoading(msg, URL) [CoreSVP showSVPLoadingWithMsg:msg url:URL];
20 | #define CoreSVPBottomMsg(msg, CompleteBlock) [CoreSVP showSVPWithType:CoreSVPTypeBottomMsg Msg:msg duration:2 allowEdit:NO beginBlock:nil completeBlock:CompleteBlock];
21 | #define CoreSVPDismiss [CoreSVP dismiss];
22 | #define CoreSVPDismissDelay(delay) [CoreSVP dismiss:delay];
23 |
24 |
25 | typedef enum {
26 |
27 | /** 默认无状态 */
28 | CoreSVPTypeNone = 0,
29 |
30 | /** 无图片普通提示,显示在屏幕正中间 */
31 | CoreSVPTypeCenterMsg,
32 |
33 | /** 无图片普通提示,显示在屏幕下方,tabbar之上 */
34 | CoreSVPTypeBottomMsg,
35 |
36 | /** Info */
37 | CoreSVPTypeInfo,
38 |
39 | /** Progress */
40 | CoreSVPTypeLoadingInterface,
41 |
42 | /** error */
43 | CoreSVPTypeError,
44 |
45 | /** success */
46 | CoreSVPTypeSuccess
47 |
48 | }CoreSVPType;
49 |
50 |
51 |
52 |
53 |
54 | @interface CoreSVP : NSObject
55 |
56 |
57 |
58 |
59 | /**
60 | * 展示提示框
61 | *
62 | * @param type 类型
63 | * @param msg 文字
64 | * @param duration 时间(当type=CoreSVPTypeLoadingInterface时无效)
65 | * @param allowEdit 否允许编辑
66 | * @param beginBlock 提示开始时的回调
67 | * @param completeBlock 提示结束时的回调
68 | */
69 | +(void)showSVPWithType:(CoreSVPType)type Msg:(NSString *)msg duration:(CGFloat)duration allowEdit:(BOOL)allowEdit beginBlock:(void(^)())beginBlock completeBlock:(void(^)())completeBlock;
70 |
71 |
72 |
73 |
74 | /*
75 | * 进度
76 | */
77 | +(void)showProgess:(CGFloat)progress Msg:(NSString *)msg maskType:(SVProgressHUDMaskType)maskType;
78 |
79 |
80 | /*
81 | * 加载中
82 | */
83 | +(void)showSVPLoadingWithMsg:(NSString *)msg url:(NSString *)url;
84 |
85 |
86 |
87 | /**
88 | * 隐藏提示框
89 | */
90 | +(void)dismiss;
91 | +(void)dismiss:(NSTimeInterval)delay;
92 |
93 |
94 | @end
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreSVP/Lib/SVP.bundle/green@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CharlinFeng/CoreHttp/bf3b098b831fc55fc3f4314be04bea70dbdbfcb3/CoreHttp/FrameWorks/CoreSVP/Lib/SVP.bundle/green@2x.png
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreSVP/Lib/SVP.bundle/green@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CharlinFeng/CoreHttp/bf3b098b831fc55fc3f4314be04bea70dbdbfcb3/CoreHttp/FrameWorks/CoreSVP/Lib/SVP.bundle/green@3x.png
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreSVP/Lib/SVP.bundle/red@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CharlinFeng/CoreHttp/bf3b098b831fc55fc3f4314be04bea70dbdbfcb3/CoreHttp/FrameWorks/CoreSVP/Lib/SVP.bundle/red@2x.png
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreSVP/Lib/SVP.bundle/red@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CharlinFeng/CoreHttp/bf3b098b831fc55fc3f4314be04bea70dbdbfcb3/CoreHttp/FrameWorks/CoreSVP/Lib/SVP.bundle/red@3x.png
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreSVP/Lib/SVP.bundle/yellow@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CharlinFeng/CoreHttp/bf3b098b831fc55fc3f4314be04bea70dbdbfcb3/CoreHttp/FrameWorks/CoreSVP/Lib/SVP.bundle/yellow@2x.png
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreSVP/Lib/SVProgressHUD/SVIndefiniteAnimatedView.h:
--------------------------------------------------------------------------------
1 | //
2 | // SVIndefiniteAnimatedView.h
3 | // SVProgressHUD
4 | //
5 | // Created by Guillaume Campagna on 2014-12-05.
6 | //
7 | //
8 |
9 | #import
10 |
11 | @interface SVIndefiniteAnimatedView : UIView
12 |
13 | @property (nonatomic, assign) CGFloat strokeThickness;
14 | @property (nonatomic, assign) CGFloat radius;
15 | @property (nonatomic, strong) UIColor *strokeColor;
16 |
17 | @end
18 |
19 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreSVP/Lib/SVProgressHUD/SVProgressHUD-Prefix.pch:
--------------------------------------------------------------------------------
1 | //
2 | // Prefix header for all source files of the 'SVProgressHUD' target in the 'SVProgressHUD' project
3 | //
4 |
5 | #ifdef __OBJC__
6 | #import
7 | #endif
8 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreSVP/Lib/SVProgressHUD/SVProgressHUD.bundle/angle-mask.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CharlinFeng/CoreHttp/bf3b098b831fc55fc3f4314be04bea70dbdbfcb3/CoreHttp/FrameWorks/CoreSVP/Lib/SVProgressHUD/SVProgressHUD.bundle/angle-mask.png
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreSVP/Lib/SVProgressHUD/SVProgressHUD.bundle/angle-mask@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CharlinFeng/CoreHttp/bf3b098b831fc55fc3f4314be04bea70dbdbfcb3/CoreHttp/FrameWorks/CoreSVP/Lib/SVProgressHUD/SVProgressHUD.bundle/angle-mask@2x.png
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreSVP/Lib/SVProgressHUD/SVProgressHUD.bundle/angle-mask@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CharlinFeng/CoreHttp/bf3b098b831fc55fc3f4314be04bea70dbdbfcb3/CoreHttp/FrameWorks/CoreSVP/Lib/SVProgressHUD/SVProgressHUD.bundle/angle-mask@3x.png
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreSVP/Lib/SVProgressHUD/SVProgressHUD.bundle/error.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CharlinFeng/CoreHttp/bf3b098b831fc55fc3f4314be04bea70dbdbfcb3/CoreHttp/FrameWorks/CoreSVP/Lib/SVProgressHUD/SVProgressHUD.bundle/error.png
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreSVP/Lib/SVProgressHUD/SVProgressHUD.bundle/error@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CharlinFeng/CoreHttp/bf3b098b831fc55fc3f4314be04bea70dbdbfcb3/CoreHttp/FrameWorks/CoreSVP/Lib/SVProgressHUD/SVProgressHUD.bundle/error@2x.png
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreSVP/Lib/SVProgressHUD/SVProgressHUD.bundle/error@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CharlinFeng/CoreHttp/bf3b098b831fc55fc3f4314be04bea70dbdbfcb3/CoreHttp/FrameWorks/CoreSVP/Lib/SVProgressHUD/SVProgressHUD.bundle/error@3x.png
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreSVP/Lib/SVProgressHUD/SVProgressHUD.bundle/info.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CharlinFeng/CoreHttp/bf3b098b831fc55fc3f4314be04bea70dbdbfcb3/CoreHttp/FrameWorks/CoreSVP/Lib/SVProgressHUD/SVProgressHUD.bundle/info.png
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreSVP/Lib/SVProgressHUD/SVProgressHUD.bundle/info@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CharlinFeng/CoreHttp/bf3b098b831fc55fc3f4314be04bea70dbdbfcb3/CoreHttp/FrameWorks/CoreSVP/Lib/SVProgressHUD/SVProgressHUD.bundle/info@2x.png
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreSVP/Lib/SVProgressHUD/SVProgressHUD.bundle/info@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CharlinFeng/CoreHttp/bf3b098b831fc55fc3f4314be04bea70dbdbfcb3/CoreHttp/FrameWorks/CoreSVP/Lib/SVProgressHUD/SVProgressHUD.bundle/info@3x.png
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreSVP/Lib/SVProgressHUD/SVProgressHUD.bundle/success.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CharlinFeng/CoreHttp/bf3b098b831fc55fc3f4314be04bea70dbdbfcb3/CoreHttp/FrameWorks/CoreSVP/Lib/SVProgressHUD/SVProgressHUD.bundle/success.png
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreSVP/Lib/SVProgressHUD/SVProgressHUD.bundle/success@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CharlinFeng/CoreHttp/bf3b098b831fc55fc3f4314be04bea70dbdbfcb3/CoreHttp/FrameWorks/CoreSVP/Lib/SVProgressHUD/SVProgressHUD.bundle/success@2x.png
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreSVP/Lib/SVProgressHUD/SVProgressHUD.bundle/success@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CharlinFeng/CoreHttp/bf3b098b831fc55fc3f4314be04bea70dbdbfcb3/CoreHttp/FrameWorks/CoreSVP/Lib/SVProgressHUD/SVProgressHUD.bundle/success@3x.png
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreSVP/Lib/SVProgressHUD/SVProgressHUD.h:
--------------------------------------------------------------------------------
1 | //
2 | // SVProgressHUD.h
3 | //
4 | // Copyright 2011-2014 Sam Vermette. All rights reserved.
5 | //
6 | // https://github.com/samvermette/SVProgressHUD
7 | //
8 |
9 | #import
10 | #import
11 |
12 | extern NSString * const SVProgressHUDDidReceiveTouchEventNotification;
13 | extern NSString * const SVProgressHUDDidTouchDownInsideNotification;
14 | extern NSString * const SVProgressHUDWillDisappearNotification;
15 | extern NSString * const SVProgressHUDDidDisappearNotification;
16 | extern NSString * const SVProgressHUDWillAppearNotification;
17 | extern NSString * const SVProgressHUDDidAppearNotification;
18 |
19 | extern NSString * const SVProgressHUDStatusUserInfoKey;
20 |
21 | typedef NS_ENUM(NSUInteger, SVProgressHUDMaskType) {
22 | SVProgressHUDMaskTypeNone = 1, // allow user interactions while HUD is displayed
23 | SVProgressHUDMaskTypeClear, // don't allow user interactions
24 | SVProgressHUDMaskTypeBlack, // don't allow user interactions and dim the UI in the back of the HUD
25 | SVProgressHUDMaskTypeGradient // don't allow user interactions and dim the UI with a a-la-alert-view background gradient
26 | };
27 |
28 | #define SVProgressHUDURLNoti @"SVProgressHUDURLNoti"
29 |
30 | @interface SVProgressHUD : UIView
31 |
32 | #pragma mark - Customization
33 |
34 | + (void)setBackgroundColor:(UIColor*)color; // default is [UIColor whiteColor]
35 | + (void)setForegroundColor:(UIColor*)color; // default is [UIColor blackColor]
36 | + (void)setCornerRadius:(CGFloat)cornerRadius; // default is 14 pt
37 | + (void)setRingThickness:(CGFloat)width; // default is 4 pt
38 | + (void)setFont:(UIFont*)font; // default is [UIFont preferredFontForTextStyle:UIFontTextStyleSubheadline]
39 | + (void)setInfoImage:(UIImage*)image; // default is the bundled info image provided by Freepik
40 | + (void)setSuccessImage:(UIImage*)image; // default is the bundled success image provided by Freepik
41 | + (void)setErrorImage:(UIImage*)image; // default is the bundled error image provided by Freepik
42 | + (void)setDefaultMaskType:(SVProgressHUDMaskType)maskType; // default is SVProgressHUDMaskTypeNone
43 | + (void)setViewForExtension:(UIView*)view; // default is nil, only used if #define SV_APP_EXTENSIONS is set
44 |
45 | #pragma mark - Show Methods
46 |
47 | + (void)show;
48 | + (void)showWithMaskType:(SVProgressHUDMaskType)maskType;
49 | + (void)showWithStatus:(NSString*)status;
50 | + (void)showWithStatus:(NSString*)status maskType:(SVProgressHUDMaskType)maskType;
51 |
52 | + (void)showProgress:(float)progress;
53 | + (void)showProgress:(float)progress maskType:(SVProgressHUDMaskType)maskType;
54 | + (void)showProgress:(float)progress status:(NSString*)status;
55 | + (void)showProgress:(float)progress status:(NSString*)status maskType:(SVProgressHUDMaskType)maskType;
56 |
57 | + (void)setStatus:(NSString*)string; // change the HUD loading status while it's showing
58 |
59 | // stops the activity indicator, shows a glyph + status, and dismisses HUD a little bit later
60 | + (void)showInfoWithStatus:(NSString *)string;
61 | + (void)showInfoWithStatus:(NSString *)string maskType:(SVProgressHUDMaskType)maskType;
62 |
63 | + (void)showSuccessWithStatus:(NSString*)string;
64 | + (void)showSuccessWithStatus:(NSString*)string maskType:(SVProgressHUDMaskType)maskType;
65 |
66 | + (void)showErrorWithStatus:(NSString *)string;
67 | + (void)showErrorWithStatus:(NSString *)string maskType:(SVProgressHUDMaskType)maskType;
68 |
69 | // use 28x28 white pngs
70 | + (void)showImage:(UIImage*)image status:(NSString*)status;
71 | + (void)showImage:(UIImage*)image status:(NSString*)status maskType:(SVProgressHUDMaskType)maskType;
72 |
73 | + (void)setOffsetFromCenter:(UIOffset)offset;
74 | + (void)resetOffsetFromCenter;
75 |
76 | + (void)popActivity; // decrease activity count, if activity count == 0 the HUD is dismissed
77 | + (void)dismiss;
78 | + (void)isProgressRes:(BOOL)res;
79 |
80 | + (void)setURL:(NSString *)url;
81 |
82 | + (BOOL)isVisible;
83 |
84 |
85 |
86 |
87 |
88 | /** 对HUB进行扩展 */
89 | +(void)setDuration:(NSTimeInterval)duration;
90 |
91 | @end
92 |
93 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreStatus/CoreStatus.h:
--------------------------------------------------------------------------------
1 | //
2 | // CoreNetWorkStatusObserver.h
3 | // CoreNetWorkStatusObserver
4 | //
5 | // Created by LiHaozhen on 15/5/2.
6 | // Copyright (c) 2015年 ihojin. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "Reachability.h"
11 | #import "CoreNetWorkStatus.h"
12 | #import "CoreStatusSingleton.h"
13 | #import "CoreStatusProtocol.h"
14 |
15 |
16 |
17 | @interface CoreStatus : NSObject
18 | HMSingletonH(CoreStatus)
19 |
20 |
21 | /** 获取当前网络状态:枚举 */
22 | +(CoreNetWorkStatus)currentNetWorkStatus;
23 |
24 | /** 获取当前网络状态:字符串 */
25 | +(NSString *)currentNetWorkStatusString;
26 |
27 |
28 | /** 开始网络监听 */
29 | +(void)beginNotiNetwork:(id)listener;
30 |
31 | /** 停止网络监听 */
32 | +(void)endNotiNetwork:(id)listener;
33 |
34 |
35 |
36 | /*
37 | * 新增API
38 | */
39 | /** 是否是Wifi */
40 | +(BOOL)isWifiEnable;
41 |
42 | /** 是否有网络 */
43 | +(BOOL)isNetworkEnable;
44 |
45 | /** 是否处于高速网络环境:3G、4G、Wifi */
46 | +(BOOL)isHighSpeedNetwork;
47 |
48 |
49 |
50 | @end
51 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreStatus/Lib/CoreNetworkStatus.h:
--------------------------------------------------------------------------------
1 | //
2 | // CoreCoreNetWorkStatus.h
3 | // CoreStatus
4 | //
5 | // Created by 成林 on 15/7/6.
6 | // Copyright (c) 2015年 muxi. All rights reserved.
7 | //
8 |
9 | #ifndef CoreStatus_CoreCoreNetWorkStatus_h
10 | #define CoreStatus_CoreCoreNetWorkStatus_h
11 |
12 | /** 网络状态 */
13 | typedef enum{
14 |
15 | /** 无网络 */
16 | CoreNetWorkStatusNone=0,
17 |
18 | /** Wifi网络 */
19 | CoreNetWorkStatusWifi,
20 |
21 | /** 蜂窝网络 */
22 | CoreNetWorkStatusWWAN,
23 |
24 | /** 2G网络 */
25 | CoreNetWorkStatus2G,
26 |
27 | /** 3G网络 */
28 | CoreNetWorkStatus3G,
29 |
30 | /** 4G网络 */
31 | CoreNetWorkStatus4G,
32 |
33 | //未知网络
34 | CoreNetWorkStatusUnkhow
35 |
36 | }CoreNetWorkStatus;
37 |
38 |
39 |
40 |
41 | #endif
42 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreStatus/Lib/CoreStatusProtocol.h:
--------------------------------------------------------------------------------
1 | //
2 | // CoreStatusProtocol.h
3 | // CoreStatus
4 | //
5 | // Created by 成林 on 15/7/6.
6 | // Copyright (c) 2015年 muxi. All rights reserved.
7 | //
8 |
9 | #ifndef CoreStatus_CoreStatusProtocol_h
10 | #define CoreStatus_CoreStatusProtocol_h
11 | #import "CoreNetworkStatus.h"
12 |
13 | @protocol CoreStatusProtocol
14 |
15 | @property (nonatomic,assign) NetworkStatus currentStatus;
16 |
17 | @optional
18 |
19 | /** 网络状态变更 */
20 | -(void)coreNetworkChangeNoti:(NSNotification *)noti;
21 |
22 | @end
23 |
24 |
25 |
26 |
27 |
28 |
29 | #endif
30 |
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreStatus/Lib/Reachability/Reachability.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2016 Apple Inc. All Rights Reserved.
3 | See LICENSE.txt for this sample’s licensing information
4 |
5 | Abstract:
6 | Basic demonstration of how to use the SystemConfiguration Reachablity APIs.
7 | */
8 |
9 | #import
10 | #import
11 | #import
12 |
13 |
14 | typedef enum : NSInteger {
15 | NotReachable = 0,
16 | ReachableViaWiFi,
17 | ReachableViaWWAN
18 | } NetworkStatus;
19 |
20 | #pragma mark IPv6 Support
21 | //Reachability fully support IPv6. For full details, see ReadMe.md.
22 |
23 |
24 | extern NSString *kReachabilityChangedNotification;
25 |
26 |
27 | @interface Reachability : NSObject
28 |
29 | /*!
30 | * Use to check the reachability of a given host name.
31 | */
32 | + (instancetype)reachabilityWithHostName:(NSString *)hostName;
33 |
34 | /*!
35 | * Use to check the reachability of a given IP address.
36 | */
37 | + (instancetype)reachabilityWithAddress:(const struct sockaddr *)hostAddress;
38 |
39 | /*!
40 | * Checks whether the default route is available. Should be used by applications that do not connect to a particular host.
41 | */
42 | + (instancetype)reachabilityForInternetConnection;
43 |
44 |
45 | #pragma mark reachabilityForLocalWiFi
46 | //reachabilityForLocalWiFi has been removed from the sample. See ReadMe.md for more information.
47 | //+ (instancetype)reachabilityForLocalWiFi;
48 |
49 | /*!
50 | * Start listening for reachability notifications on the current run loop.
51 | */
52 | - (BOOL)startNotifier;
53 | - (void)stopNotifier;
54 |
55 | - (NetworkStatus)currentReachabilityStatus;
56 |
57 | /*!
58 | * WWAN may be available, but not active until a connection has been established. WiFi may require a connection for VPN on Demand.
59 | */
60 | - (BOOL)connectionRequired;
61 |
62 | @end
--------------------------------------------------------------------------------
/CoreHttp/FrameWorks/CoreStatus/Lib/Singleton/CoreStatusSingleton.h:
--------------------------------------------------------------------------------
1 | // .h文件
2 | #define HMSingletonH(name) + (instancetype)shared##name;
3 |
4 | // .m文件
5 | #if __has_feature(objc_arc)
6 |
7 | #define HMSingletonM(name) \
8 | static id _instace; \
9 | \
10 | + (id)allocWithZone:(struct _NSZone *)zone \
11 | { \
12 | static dispatch_once_t onceToken; \
13 | dispatch_once(&onceToken, ^{ \
14 | _instace = [super allocWithZone:zone]; \
15 | }); \
16 | return _instace; \
17 | } \
18 | \
19 | + (instancetype)shared##name \
20 | { \
21 | static dispatch_once_t onceToken; \
22 | dispatch_once(&onceToken, ^{ \
23 | _instace = [[self alloc] init]; \
24 | }); \
25 | return _instace; \
26 | } \
27 | \
28 | - (id)copyWithZone:(NSZone *)zone \
29 | { \
30 | return _instace; \
31 | }
32 |
33 | #else
34 |
35 | #define HMSingletonM(name) \
36 | static id _instace; \
37 | \
38 | + (id)allocWithZone:(struct _NSZone *)zone \
39 | { \
40 | static dispatch_once_t onceToken; \
41 | dispatch_once(&onceToken, ^{ \
42 | _instace = [super allocWithZone:zone]; \
43 | }); \
44 | return _instace; \
45 | } \
46 | \
47 | + (instancetype)shared##name \
48 | { \
49 | static dispatch_once_t onceToken; \
50 | dispatch_once(&onceToken, ^{ \
51 | _instace = [[self alloc] init]; \
52 | }); \
53 | return _instace; \
54 | } \
55 | \
56 | - (id)copyWithZone:(NSZone *)zone \
57 | { \
58 | return _instace; \
59 | } \
60 | \
61 | - (oneway void)release { } \
62 | - (id)retain { return self; } \
63 | - (NSUInteger)retainCount { return 1;} \
64 | - (id)autorelease { return self;}
65 |
66 | #endif
--------------------------------------------------------------------------------
/CoreHttp/Images.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 | }
--------------------------------------------------------------------------------
/CoreHttp/Images.xcassets/LaunchImage.launchimage/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "orientation" : "portrait",
5 | "idiom" : "iphone",
6 | "minimum-system-version" : "7.0",
7 | "scale" : "2x"
8 | },
9 | {
10 | "orientation" : "portrait",
11 | "idiom" : "iphone",
12 | "minimum-system-version" : "7.0",
13 | "subtype" : "retina4",
14 | "scale" : "2x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/CoreHttp/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | com.huaxi.$(PRODUCT_NAME:rfc1034identifier)
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 |
--------------------------------------------------------------------------------
/CoreHttp/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // CoreHttp
4 | //
5 | // Created by muxi on 15/3/2.
6 | // Copyright (c) 2015年 muxi. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/CoreHttp/ViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.m
3 | // CoreHttp
4 | //
5 | // Created by muxi on 15/3/2.
6 | // Copyright (c) 2015年 muxi. All rights reserved.
7 | //
8 |
9 | #import "ViewController.h"
10 | #import "APPHttp.h"
11 | #import "CoreSVP.h"
12 |
13 | @interface ViewController ()
14 |
15 | @property (nonatomic,strong) NSOperationQueue *queue;
16 |
17 | @end
18 |
19 | @implementation ViewController
20 |
21 | - (void)viewDidLoad {
22 | [super viewDidLoad];
23 |
24 | [self beginAction:nil];
25 |
26 | self.view.backgroundColor = [UIColor redColor];
27 | }
28 |
29 |
30 | - (IBAction)beginAction:(id)sender {
31 |
32 | UIImage *img = [UIImage imageNamed:@"cut"];
33 |
34 | NSData *data = UIImageJPEGRepresentation(img, 1) ;
35 |
36 | NSDictionary *params = @{@"token":@"8888",@"attach_id":@"1"};
37 |
38 | NSMutableArray *arr = [NSMutableArray array];
39 | // 4226524
40 |
41 | for (NSUInteger i = 0; i< 1; i++) {
42 |
43 | UploadFile *file = [UploadFile fileWithKey:@"icon" data:data name:[NSString stringWithFormat:@"%i.jpg",i]];
44 |
45 | [arr addObject:file];
46 | }
47 |
48 | NSString *url = @"http://112.74.125.78/yeah/index.php/Home/User/delete_attach";
49 |
50 | [APPHttp uploadUrl:url params:params files:arr target:self.view type:APPHttpTypeStatusView progressBlock:^(CGFloat p) {
51 | NSLog(@"上传中%f",p);
52 | } success:^(id obj) {
53 | NSLog(@"成功");
54 | } errorBlock:^(CoreHttpErrorType errorType, NSString *errorMsg) {
55 | NSLog(@"失败");
56 | }];
57 |
58 | }
59 |
60 |
61 | - (IBAction)endAction:(id)sender {
62 |
63 |
64 | }
65 |
66 | -(void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didSendBodyData:(int64_t)bytesSent totalBytesSent:(int64_t)totalBytesSent totalBytesExpectedToSend:(int64_t)totalBytesExpectedToSend{
67 |
68 | CGFloat p = totalBytesSent/(CGFloat)totalBytesExpectedToSend;
69 |
70 | NSLog(@"didSendBodyData:%f,%@,%@",p,@(totalBytesSent),@(totalBytesExpectedToSend));
71 | }
72 |
73 | -(void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didCompleteWithError:(NSError *)error{
74 |
75 | NSLog(@"上传完成:%@",error);
76 | }
77 |
78 |
79 | @end
80 |
--------------------------------------------------------------------------------
/CoreHttp/charlin.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CharlinFeng/CoreHttp/bf3b098b831fc55fc3f4314be04bea70dbdbfcb3/CoreHttp/charlin.jpg
--------------------------------------------------------------------------------
/CoreHttp/cut.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CharlinFeng/CoreHttp/bf3b098b831fc55fc3f4314be04bea70dbdbfcb3/CoreHttp/cut.png
--------------------------------------------------------------------------------
/CoreHttp/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // CoreHttp
4 | //
5 | // Created by muxi on 15/3/2.
6 | // Copyright (c) 2015年 muxi. 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 |
--------------------------------------------------------------------------------
/CoreHttpTests/CoreHttpTests.m:
--------------------------------------------------------------------------------
1 | //
2 | // CoreHttpTests.m
3 | // CoreHttpTests
4 | //
5 | // Created by muxi on 15/3/2.
6 | // Copyright (c) 2015年 muxi. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | @interface CoreHttpTests : XCTestCase
13 |
14 | @end
15 |
16 | @implementation CoreHttpTests
17 |
18 | - (void)setUp {
19 | [super setUp];
20 | // Put setup code here. This method is called before the invocation of each test method in the class.
21 | }
22 |
23 | - (void)tearDown {
24 | // Put teardown code here. This method is called after the invocation of each test method in the class.
25 | [super tearDown];
26 | }
27 |
28 | - (void)testExample {
29 | // This is an example of a functional test case.
30 | XCTAssert(YES, @"Pass");
31 | }
32 |
33 | - (void)testPerformanceExample {
34 | // This is an example of a performance test case.
35 | [self measureBlock:^{
36 | // Put the code you want to measure the time of here.
37 | }];
38 | }
39 |
40 | @end
41 |
--------------------------------------------------------------------------------
/CoreHttpTests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | com.huaxi.$(PRODUCT_NAME:rfc1034identifier)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 |
24 |
25 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | Charlin出框架的目标:简单、易用、实用、高度封装、绝对解耦!
4 |
5 |
6 | #CoreHttp
7 | ####抛弃AFN,网络处理工具类,将网络交互玩于股掌间的利器!
8 |
9 |
10 | #### 框架依赖:
11 | .CoreStatus
12 |
13 | 若使用APP级别APPHttp,还需要依赖以下框架:
14 | .CoreToast
15 | .CoreBtn
16 |
17 |
18 |
19 |
20 | #### 框架特性:
21 | >1.自己写网络请求框架,我从来不用AFN,ASI。
22 | >2.自己完全定制了整个网络请求的所有流程:GET/POST/UPLOAD,您不会错过任何一个细节!
23 | >3.有了他,您可以轻松完成GET/POST请求,多文件上传,以及全方位的错误捕捉。自己写一套框架完全掌握整个网络请求!把控任何一个网络请求成败细节!
24 | >4.此框架首度公开,长期修改的最终精华体现!
25 | >5.支持普通数据交互、JSON交互。
26 | >6.友好的面向对象封装文件上传,详情的错误处理,数据解析。
27 | >7.考虑了网络实时状态,封装了网络请求指示器(状态栏指示器)。
28 | >8.绝对解耦,本框架不需要依赖任何第三方!无公害,绿色环保无污染!
29 |
30 |
31 |
32 |
33 |
34 | -----
35 | CoreHttp 抛弃AFN,网络处理工具类,将网络交互玩于股掌间的利器!
36 | -----
37 |
38 |
39 |
40 |
41 |
42 | #### 版权说明 RIGHTS
43 | 作品说明:本框架由iOS开发攻城狮Charlin制作。
44 | 作品时间: 2013年初
45 |
46 | #### 关于Chariln INTRODUCE
47 | 作者简介:Charlin-四川成都华西都市报旗下华西都市网络有限公司技术部iOS工程师!
48 |
49 |
50 | #### 联系方式 CONTACT
51 | Q Q:1761904945(请注明缘由)
52 | Mail:1761904945@qq.com
53 |
54 |
--------------------------------------------------------------------------------