├── .gitignore ├── LICENCE ├── README.md ├── YBHud.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ ├── xcshareddata │ │ └── IDEWorkspaceChecks.plist │ └── xcuserdata │ │ └── yahya.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── yahya.xcuserdatad │ ├── xcdebugger │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ ├── YBHud.xcscheme │ └── xcschememanagement.plist └── YBHud ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets ├── AppIcon.appiconset │ ├── Contents.json │ ├── Icon-App-20x20@1x.png │ ├── Icon-App-20x20@2x-1.png │ ├── Icon-App-20x20@2x.png │ ├── Icon-App-20x20@3x.png │ ├── Icon-App-29x29@1x.png │ ├── Icon-App-29x29@2x-1.png │ ├── Icon-App-29x29@2x.png │ ├── Icon-App-29x29@3x.png │ ├── Icon-App-40x40@1x.png │ ├── Icon-App-40x40@2x-1.png │ ├── Icon-App-40x40@2x.png │ ├── Icon-App-40x40@3x.png │ ├── Icon-App-60x60@2x.png │ ├── Icon-App-60x60@3x.png │ ├── Icon-App-76x76@1x.png │ ├── Icon-App-76x76@2x.png │ ├── Icon-App-83.5x83.5@2x.png │ └── ItunesArtwork@2x.png └── Contents.json ├── Base.lproj └── LaunchScreen.storyboard ├── Cell ├── CustomCell.h ├── CustomCell.m └── CustomCell.xib ├── DGActivityIndicatorView ├── Animations │ ├── DGActivityIndicatorAnimation.h │ ├── DGActivityIndicatorAnimation.m │ ├── 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 ├── Images ├── YBHud_1.gif ├── YBHud_2.gif ├── YBHud_3.gif ├── YBHud_4.gif ├── YBHud_5.gif └── YBHud_Logo.png ├── Info.plist ├── ViewController ├── ViewController.h ├── ViewController.m └── ViewController.xib ├── YBHud ├── YBHud.h └── YBHud.m └── main.m /.gitignore: -------------------------------------------------------------------------------- 1 | # Adapted from https://github.com/github/gitignore/blob/master/Objective-C.gitignore 2 | 3 | # Finder 4 | .DS_Store 5 | 6 | # Xcode 7 | ## Build generated 8 | build/ 9 | DerivedData/ 10 | 11 | ## Various settings 12 | *.pbxuser 13 | !default.pbxuser 14 | *.mode1v3 15 | !default.mode1v3 16 | *.mode2v3 17 | !default.mode2v3 18 | *.perspectivev3 19 | !default.perspectivev3 20 | xcuserdata/ 21 | 22 | ## Other 23 | *.moved-aside 24 | *.xccheckout 25 | *.xcscmblueprint 26 | 27 | ## Obj-C/Swift specific 28 | *.hmap 29 | *.ipa 30 | *.dSYM.zip 31 | *.dSYM 32 | 33 | # CocoaPods 34 | # 35 | # We recommend against adding the Pods directory to your .gitignore. However 36 | # you should judge for yourself, the pros and cons are mentioned at: 37 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 38 | 39 | Pods/ 40 | 41 | # Add this line if you want to avoid checking in source code from the Xcode workspace 42 | # *.xcworkspace 43 | 44 | # Carthage 45 | # 46 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 47 | # Carthage/Checkouts 48 | 49 | Carthage/Build 50 | 51 | # fastlane 52 | # 53 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 54 | # screenshots whenever they are needed. 55 | # For more information about the recommended setup visit: 56 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 57 | 58 | fastlane/report.xml 59 | fastlane/Preview.html 60 | fastlane/screenshots/**/*.png 61 | fastlane/test_output 62 | 63 | # Code Injection 64 | # 65 | # After new code Injection tools there's a generated folder /iOSInjectionProject 66 | # https://github.com/johnno1962/injectionforxcode 67 | 68 | iOSInjectionProject/ 69 | -------------------------------------------------------------------------------- /LICENCE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Yahya Bagia 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # YBHud 2 | A progress hud using [DGActivityIndicatorView](https://github.com/gontovnik/DGActivityIndicatorView). 3 | 4 | ![](https://github.com/YahyaBagia/YBHud/blob/master/YBHud/Images/YBHud_Logo.png) 5 | 6 | ### Screenshot 7 | | ![](https://github.com/YahyaBagia/YBHud/blob/master/YBHud/Images/YBHud_1.gif)| ![](https://github.com/YahyaBagia/YBHud/blob/master/YBHud/Images/YBHud_2.gif) | ![](https://github.com/YahyaBagia/YBHud/blob/master/YBHud/Images/YBHud_3.gif)| 8 | | ------------- |:-------------:| -----:| 9 | 10 | |![](https://github.com/YahyaBagia/YBHud/blob/master/YBHud/Images/YBHud_4.gif)|![](https://github.com/YahyaBagia/YBHud/blob/master/YBHud/Images/YBHud_5.gif)| 11 | | ------------- | -------------: | 12 | 13 | ### Installation 14 | Drag and Drop files (YBHud.h & YBHud.m) from YBHud Directory into your XCode Project Directory. Add DGActivityIndicatorView in your project. 15 | 16 | ### Usage 17 | ``` 18 | YBHud *hud = [[YBHud alloc]initWithHudType:DGActivityIndicatorAnimationTypeCookieTerminator]; //Initialization 19 | 20 | //Optional Tint Color (Indicator Color) 21 | //hud.tintColor = [UIColor blackColor]; 22 | 23 | //Optional User Interaction 24 | //hud.UserInteractionDisabled = YES; (User can interact with background views while HUD is displayed) 25 | 26 | //Optional HUD Color 27 | //hud.hudColor = [UIColor yellowColor]; 28 | 29 | //Optional Dim Amount of HUD 30 | //hud.dimAmount = 0.5; 31 | 32 | //Display HUD 33 | [hud showInView:self.view animated:YES]; 34 | 35 | //Dismiss HUD 36 | [hud dismissAnimated:YES]; 37 | ``` 38 | ### Requirements 39 | iOS 9.0+ 40 | 41 | ### License 42 | MIT License 43 | -------------------------------------------------------------------------------- /YBHud.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /YBHud.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /YBHud.xcodeproj/project.xcworkspace/xcuserdata/yahya.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YahyaBagia/YBHud/9048131581671c1baa1fcb92c912d8eb5c18bd75/YBHud.xcodeproj/project.xcworkspace/xcuserdata/yahya.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /YBHud.xcodeproj/xcuserdata/yahya.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /YBHud.xcodeproj/xcuserdata/yahya.xcuserdatad/xcschemes/YBHud.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /YBHud.xcodeproj/xcuserdata/yahya.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | YBHud.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 08C287041E448CD80006FA1C 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /YBHud/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // YBHud 4 | // 5 | // Created by Yahya on 03/02/17. 6 | // Copyright © 2017 yahya. 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 | -------------------------------------------------------------------------------- /YBHud/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // YBHud 4 | // 5 | // Created by Yahya on 03/02/17. 6 | // Copyright © 2017 yahya. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | #import "ViewController.h" 11 | 12 | @interface AppDelegate () 13 | 14 | @end 15 | 16 | @implementation AppDelegate 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | _window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 20 | _window.rootViewController = [ViewController new]; 21 | [_window makeKeyAndVisible]; 22 | return YES; 23 | } 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /YBHud/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "20x20", 5 | "idiom" : "iphone", 6 | "filename" : "Icon-App-20x20@2x.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "20x20", 11 | "idiom" : "iphone", 12 | "filename" : "Icon-App-20x20@3x.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "29x29", 17 | "idiom" : "iphone", 18 | "filename" : "Icon-App-29x29@2x.png", 19 | "scale" : "2x" 20 | }, 21 | { 22 | "size" : "29x29", 23 | "idiom" : "iphone", 24 | "filename" : "Icon-App-29x29@3x.png", 25 | "scale" : "3x" 26 | }, 27 | { 28 | "size" : "40x40", 29 | "idiom" : "iphone", 30 | "filename" : "Icon-App-40x40@2x.png", 31 | "scale" : "2x" 32 | }, 33 | { 34 | "size" : "40x40", 35 | "idiom" : "iphone", 36 | "filename" : "Icon-App-40x40@3x.png", 37 | "scale" : "3x" 38 | }, 39 | { 40 | "size" : "60x60", 41 | "idiom" : "iphone", 42 | "filename" : "Icon-App-60x60@2x.png", 43 | "scale" : "2x" 44 | }, 45 | { 46 | "size" : "60x60", 47 | "idiom" : "iphone", 48 | "filename" : "Icon-App-60x60@3x.png", 49 | "scale" : "3x" 50 | }, 51 | { 52 | "size" : "20x20", 53 | "idiom" : "ipad", 54 | "filename" : "Icon-App-20x20@1x.png", 55 | "scale" : "1x" 56 | }, 57 | { 58 | "size" : "20x20", 59 | "idiom" : "ipad", 60 | "filename" : "Icon-App-20x20@2x-1.png", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "size" : "29x29", 65 | "idiom" : "ipad", 66 | "filename" : "Icon-App-29x29@1x.png", 67 | "scale" : "1x" 68 | }, 69 | { 70 | "size" : "29x29", 71 | "idiom" : "ipad", 72 | "filename" : "Icon-App-29x29@2x-1.png", 73 | "scale" : "2x" 74 | }, 75 | { 76 | "size" : "40x40", 77 | "idiom" : "ipad", 78 | "filename" : "Icon-App-40x40@1x.png", 79 | "scale" : "1x" 80 | }, 81 | { 82 | "size" : "40x40", 83 | "idiom" : "ipad", 84 | "filename" : "Icon-App-40x40@2x-1.png", 85 | "scale" : "2x" 86 | }, 87 | { 88 | "size" : "76x76", 89 | "idiom" : "ipad", 90 | "filename" : "Icon-App-76x76@1x.png", 91 | "scale" : "1x" 92 | }, 93 | { 94 | "size" : "76x76", 95 | "idiom" : "ipad", 96 | "filename" : "Icon-App-76x76@2x.png", 97 | "scale" : "2x" 98 | }, 99 | { 100 | "size" : "83.5x83.5", 101 | "idiom" : "ipad", 102 | "filename" : "Icon-App-83.5x83.5@2x.png", 103 | "scale" : "2x" 104 | }, 105 | { 106 | "size" : "1024x1024", 107 | "idiom" : "ios-marketing", 108 | "filename" : "ItunesArtwork@2x.png", 109 | "scale" : "1x" 110 | } 111 | ], 112 | "info" : { 113 | "version" : 1, 114 | "author" : "xcode" 115 | } 116 | } -------------------------------------------------------------------------------- /YBHud/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YahyaBagia/YBHud/9048131581671c1baa1fcb92c912d8eb5c18bd75/YBHud/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png -------------------------------------------------------------------------------- /YBHud/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YahyaBagia/YBHud/9048131581671c1baa1fcb92c912d8eb5c18bd75/YBHud/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x-1.png -------------------------------------------------------------------------------- /YBHud/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YahyaBagia/YBHud/9048131581671c1baa1fcb92c912d8eb5c18bd75/YBHud/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png -------------------------------------------------------------------------------- /YBHud/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YahyaBagia/YBHud/9048131581671c1baa1fcb92c912d8eb5c18bd75/YBHud/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png -------------------------------------------------------------------------------- /YBHud/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YahyaBagia/YBHud/9048131581671c1baa1fcb92c912d8eb5c18bd75/YBHud/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png -------------------------------------------------------------------------------- /YBHud/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YahyaBagia/YBHud/9048131581671c1baa1fcb92c912d8eb5c18bd75/YBHud/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x-1.png -------------------------------------------------------------------------------- /YBHud/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YahyaBagia/YBHud/9048131581671c1baa1fcb92c912d8eb5c18bd75/YBHud/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png -------------------------------------------------------------------------------- /YBHud/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YahyaBagia/YBHud/9048131581671c1baa1fcb92c912d8eb5c18bd75/YBHud/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png -------------------------------------------------------------------------------- /YBHud/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YahyaBagia/YBHud/9048131581671c1baa1fcb92c912d8eb5c18bd75/YBHud/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png -------------------------------------------------------------------------------- /YBHud/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YahyaBagia/YBHud/9048131581671c1baa1fcb92c912d8eb5c18bd75/YBHud/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x-1.png -------------------------------------------------------------------------------- /YBHud/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YahyaBagia/YBHud/9048131581671c1baa1fcb92c912d8eb5c18bd75/YBHud/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png -------------------------------------------------------------------------------- /YBHud/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YahyaBagia/YBHud/9048131581671c1baa1fcb92c912d8eb5c18bd75/YBHud/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png -------------------------------------------------------------------------------- /YBHud/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YahyaBagia/YBHud/9048131581671c1baa1fcb92c912d8eb5c18bd75/YBHud/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png -------------------------------------------------------------------------------- /YBHud/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YahyaBagia/YBHud/9048131581671c1baa1fcb92c912d8eb5c18bd75/YBHud/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png -------------------------------------------------------------------------------- /YBHud/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YahyaBagia/YBHud/9048131581671c1baa1fcb92c912d8eb5c18bd75/YBHud/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png -------------------------------------------------------------------------------- /YBHud/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YahyaBagia/YBHud/9048131581671c1baa1fcb92c912d8eb5c18bd75/YBHud/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /YBHud/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YahyaBagia/YBHud/9048131581671c1baa1fcb92c912d8eb5c18bd75/YBHud/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /YBHud/Assets.xcassets/AppIcon.appiconset/ItunesArtwork@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YahyaBagia/YBHud/9048131581671c1baa1fcb92c912d8eb5c18bd75/YBHud/Assets.xcassets/AppIcon.appiconset/ItunesArtwork@2x.png -------------------------------------------------------------------------------- /YBHud/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /YBHud/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /YBHud/Cell/CustomCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // CustomCell.h 3 | // YBHud 4 | // 5 | // Created by Yahya on 03/02/17. 6 | // Copyright © 2017 yahya. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface CustomCell : UITableViewCell 12 | 13 | @property (weak, nonatomic) IBOutlet UILabel *lblTitle; 14 | @property (weak, nonatomic) IBOutlet UIView *subView; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /YBHud/Cell/CustomCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // CustomCell.m 3 | // YBHud 4 | // 5 | // Created by Yahya on 03/02/17. 6 | // Copyright © 2017 yahya. All rights reserved. 7 | // 8 | 9 | #import "CustomCell.h" 10 | 11 | @implementation CustomCell 12 | 13 | - (void)awakeFromNib { 14 | [super awakeFromNib]; 15 | } 16 | 17 | - (void)setSelected:(BOOL)selected animated:(BOOL)animated { 18 | [super setSelected:selected animated:animated]; 19 | } 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /YBHud/Cell/CustomCell.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /YBHud/DGActivityIndicatorView/Animations/DGActivityIndicatorAnimation.h: -------------------------------------------------------------------------------- 1 | // 2 | // DGActivityIndicatorAnimation.h 3 | // DGActivityIndicatorExample 4 | // 5 | // Created by Danil Gontovnik on 8/10/16. 6 | // Copyright © 2016 Danil Gontovnik. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import "DGActivityIndicatorAnimationProtocol.h" 12 | 13 | @interface DGActivityIndicatorAnimation : NSObject 14 | 15 | - (CABasicAnimation *)createBasicAnimationWithKeyPath:(NSString *)keyPath; 16 | - (CAKeyframeAnimation *)createKeyframeAnimationWithKeyPath:(NSString *)keyPath; 17 | - (CAAnimationGroup *)createAnimationGroup; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /YBHud/DGActivityIndicatorView/Animations/DGActivityIndicatorAnimation.m: -------------------------------------------------------------------------------- 1 | // 2 | // DGActivityIndicatorAnimation.m 3 | // DGActivityIndicatorExample 4 | // 5 | // Created by Danil Gontovnik on 8/10/16. 6 | // Copyright © 2016 Danil Gontovnik. All rights reserved. 7 | // 8 | 9 | #import "DGActivityIndicatorAnimation.h" 10 | 11 | @implementation DGActivityIndicatorAnimation 12 | 13 | - (CABasicAnimation *)createBasicAnimationWithKeyPath:(NSString *)keyPath { 14 | CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:keyPath]; 15 | animation.removedOnCompletion = NO; 16 | return animation; 17 | } 18 | 19 | - (CAKeyframeAnimation *)createKeyframeAnimationWithKeyPath:(NSString *)keyPath { 20 | CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:keyPath]; 21 | animation.removedOnCompletion = NO; 22 | return animation; 23 | } 24 | 25 | - (CAAnimationGroup *)createAnimationGroup { 26 | CAAnimationGroup *animationGroup = [CAAnimationGroup animation]; 27 | animationGroup.removedOnCompletion = NO; 28 | return animationGroup; 29 | } 30 | 31 | - (void)setupAnimationInLayer:(CALayer *)layer withSize:(CGSize)size tintColor:(UIColor *)tintColor { 32 | 33 | } 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /YBHud/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 "DGActivityIndicatorAnimation.h" 10 | 11 | @interface DGActivityIndicatorBallBeatAnimation: DGActivityIndicatorAnimation 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /YBHud/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 = [self createKeyframeAnimationWithKeyPath:@"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 = [self createKeyframeAnimationWithKeyPath:@"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 = [self createAnimationGroup];; 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 | -------------------------------------------------------------------------------- /YBHud/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 "DGActivityIndicatorAnimation.h" 10 | 11 | @interface DGActivityIndicatorBallClipRotateAnimation: DGActivityIndicatorAnimation 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /YBHud/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 = [self createKeyframeAnimationWithKeyPath:@"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 = [self createKeyframeAnimationWithKeyPath:@"transform.rotation.z"]; 26 | 27 | rotateAnimation.values = @[@0, @M_PI, @(2 * M_PI)]; 28 | rotateAnimation.keyTimes = scaleAnimation.keyTimes; 29 | 30 | // Animation 31 | CAAnimationGroup *animation = [self createAnimationGroup];; 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 | -------------------------------------------------------------------------------- /YBHud/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 "DGActivityIndicatorAnimation.h" 10 | 11 | @interface DGActivityIndicatorBallClipRotateMultipleAnimation: DGActivityIndicatorAnimation 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /YBHud/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 = [self createKeyframeAnimationWithKeyPath:@"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 = [self createKeyframeAnimationWithKeyPath:@"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 = [self createAnimationGroup];; 82 | 83 | animation.animations = @[scaleAnimation, rotateAnimation]; 84 | animation.repeatCount = HUGE_VALF; 85 | animation.duration = duration; 86 | 87 | return animation; 88 | } 89 | 90 | @end 91 | -------------------------------------------------------------------------------- /YBHud/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 "DGActivityIndicatorAnimation.h" 10 | 11 | @interface DGActivityIndicatorBallClipRotatePulseAnimation: DGActivityIndicatorAnimation 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /YBHud/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 = [self createKeyframeAnimationWithKeyPath:@"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 = [self createKeyframeAnimationWithKeyPath:@"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 = [self createKeyframeAnimationWithKeyPath:@"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 = [self createAnimationGroup];; 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 | -------------------------------------------------------------------------------- /YBHud/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 "DGActivityIndicatorAnimation.h" 10 | 11 | @interface DGActivityIndicatorBallGridBeatAnimation: DGActivityIndicatorAnimation 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /YBHud/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 = [self createKeyframeAnimationWithKeyPath:@"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 | -------------------------------------------------------------------------------- /YBHud/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 "DGActivityIndicatorAnimation.h" 10 | 11 | @interface DGActivityIndicatorBallGridPulseAnimation: DGActivityIndicatorAnimation 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /YBHud/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 = [self createKeyframeAnimationWithKeyPath:@"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 = [self createKeyframeAnimationWithKeyPath:@"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 = [self createAnimationGroup];; 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 | -------------------------------------------------------------------------------- /YBHud/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 "DGActivityIndicatorAnimation.h" 10 | 11 | @interface DGActivityIndicatorBallPulseAnimation: DGActivityIndicatorAnimation 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /YBHud/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 = [self createKeyframeAnimationWithKeyPath:@"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 | -------------------------------------------------------------------------------- /YBHud/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 "DGActivityIndicatorAnimation.h" 10 | 11 | @interface DGActivityIndicatorBallPulseSyncAnimation: DGActivityIndicatorAnimation 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /YBHud/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 = [self createKeyframeAnimationWithKeyPath:@"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 | -------------------------------------------------------------------------------- /YBHud/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 "DGActivityIndicatorAnimation.h" 10 | 11 | @interface DGActivityIndicatorBallRotateAnimation: DGActivityIndicatorAnimation 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /YBHud/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 = [self createKeyframeAnimationWithKeyPath:@"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 = [self createKeyframeAnimationWithKeyPath:@"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 = [self createAnimationGroup];; 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 | -------------------------------------------------------------------------------- /YBHud/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 "DGActivityIndicatorAnimation.h" 10 | 11 | @interface DGActivityIndicatorBallScaleAnimation: DGActivityIndicatorAnimation 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /YBHud/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 = [self createBasicAnimationWithKeyPath:@"transform.scale"]; 18 | 19 | scaleAnimation.duration = duration; 20 | scaleAnimation.fromValue = @0.0f; 21 | scaleAnimation.toValue = @1.0f; 22 | 23 | // Opacity animation 24 | CABasicAnimation *opacityAnimation = [self createBasicAnimationWithKeyPath:@"opacity"]; 25 | 26 | opacityAnimation.duration = duration; 27 | opacityAnimation.fromValue = @1.0f; 28 | opacityAnimation.toValue = @0.0f; 29 | 30 | // Animation 31 | CAAnimationGroup *animation = [self createAnimationGroup];; 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 | -------------------------------------------------------------------------------- /YBHud/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 "DGActivityIndicatorAnimation.h" 10 | 11 | @interface DGActivityIndicatorBallScaleMultipleAnimation: DGActivityIndicatorAnimation 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /YBHud/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 = [self createBasicAnimationWithKeyPath:@"transform.scale"]; 19 | 20 | scaleAnimation.duration = duration; 21 | scaleAnimation.fromValue = @0.0f; 22 | scaleAnimation.toValue = @1.0f; 23 | 24 | // Opacity animation 25 | CAKeyframeAnimation *opacityAnimation = [self createKeyframeAnimationWithKeyPath:@"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 = [self createAnimationGroup];; 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 | -------------------------------------------------------------------------------- /YBHud/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 "DGActivityIndicatorAnimation.h" 10 | 11 | @interface DGActivityIndicatorBallScaleRippleAnimation: DGActivityIndicatorAnimation 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /YBHud/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 = [self createKeyframeAnimationWithKeyPath:@"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 = [self createKeyframeAnimationWithKeyPath:@"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 = [self createAnimationGroup];; 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 | -------------------------------------------------------------------------------- /YBHud/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 "DGActivityIndicatorAnimation.h" 10 | 11 | @interface DGActivityIndicatorBallScaleRippleMultipleAnimation: DGActivityIndicatorAnimation 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /YBHud/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 = [self createKeyframeAnimationWithKeyPath:@"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 = [self createKeyframeAnimationWithKeyPath:@"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 = [self createAnimationGroup];; 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 | -------------------------------------------------------------------------------- /YBHud/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 "DGActivityIndicatorAnimation.h" 10 | 11 | @interface DGActivityIndicatorBallSpinFadeLoader : DGActivityIndicatorAnimation 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /YBHud/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 = [self createKeyframeAnimationWithKeyPath:@"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 = [self createKeyframeAnimationWithKeyPath:@"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 = [self createAnimationGroup];; 47 | animationGroup.animations = @[scaleAnimation, opacityAnimaton]; 48 | animationGroup.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear]; 49 | animationGroup.duration = duration; 50 | animationGroup.repeatCount = HUGE; 51 | 52 | 53 | for (int i = 0; i < 8; i++) { 54 | CALayer *circle = [self circleLayer:(M_PI_4 * i) size:circleSize origin:CGPointMake(x, y) containerSize:size color:tintColor]; 55 | animationGroup.beginTime = beginTime + [beginTimes[i] doubleValue]; 56 | 57 | [layer addSublayer:circle]; 58 | [circle addAnimation:animationGroup forKey:@"animation"]; 59 | } 60 | 61 | } 62 | 63 | 64 | - (CALayer *)circleLayer:(CGFloat)angle size:(CGFloat)size origin:(CGPoint)origin containerSize:(CGSize)containerSize color:(UIColor *)color{ 65 | CGFloat radius = containerSize.width/2; 66 | CALayer *circle = [self createLayerWith:CGSizeMake(size, size) color:color]; 67 | CGRect frame = CGRectMake((origin.x + radius * (cos(angle) + 1) - size / 2), origin.y + radius * (sin(angle) + 1) - size / 2, size, size); 68 | circle.frame = frame; 69 | 70 | return circle; 71 | } 72 | 73 | - (CALayer *)createLayerWith:(CGSize)size color:(UIColor *)color{ 74 | CAShapeLayer *layer = [CAShapeLayer layer]; 75 | UIBezierPath *path = [UIBezierPath bezierPath]; 76 | 77 | [path addArcWithCenter:CGPointMake(size.width / 2,size.height / 2) radius:(size.width / 2) startAngle:0 endAngle:2 * M_PI clockwise:NO]; 78 | layer.fillColor = color.CGColor; 79 | layer.backgroundColor = nil; 80 | layer.path = path.CGPath; 81 | 82 | return layer; 83 | } 84 | 85 | @end 86 | -------------------------------------------------------------------------------- /YBHud/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 "DGActivityIndicatorAnimation.h" 10 | 11 | @interface DGActivityIndicatorBallTrianglePathAnimation: DGActivityIndicatorAnimation 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /YBHud/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 = [self createKeyframeAnimationWithKeyPath:@"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 | -------------------------------------------------------------------------------- /YBHud/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 "DGActivityIndicatorAnimation.h" 10 | 11 | @interface DGActivityIndicatorBallZigZagAnimation: DGActivityIndicatorAnimation 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /YBHud/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 = [self createKeyframeAnimationWithKeyPath:@"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 | -------------------------------------------------------------------------------- /YBHud/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 "DGActivityIndicatorAnimation.h" 10 | 11 | @interface DGActivityIndicatorBallZigZagDeflectAnimation: DGActivityIndicatorAnimation 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /YBHud/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 = [self createKeyframeAnimationWithKeyPath:@"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 | -------------------------------------------------------------------------------- /YBHud/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 "DGActivityIndicatorAnimation.h" 10 | 11 | @interface DGActivityIndicatorCookieTerminatorAnimation: DGActivityIndicatorAnimation 12 | 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /YBHud/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 = [self createBasicAnimationWithKeyPath:@"transform"]; 46 | transformAnimation.beginTime = beginTime; 47 | transformAnimation.duration = 0.3f; 48 | transformAnimation.fromValue = [NSValue valueWithCATransform3D:CATransform3DMakeRotation((1.0f - 2.0f * i) * M_PI_4, 0.0f, 0.0f, 1.0f)]; 49 | transformAnimation.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeRotation((1.0f - 2.0f * i) * M_PI_2, 0.0f, 0.0f, 1.0f)]; 50 | transformAnimation.autoreverses = YES; 51 | transformAnimation.repeatCount = HUGE_VALF; 52 | transformAnimation.timingFunction = [CAMediaTimingFunction functionWithName: kCAMediaTimingFunctionEaseInEaseOut]; 53 | 54 | [layer addSublayer:jawLayer]; 55 | [jawLayer addAnimation:transformAnimation forKey:@"animation"]; 56 | } 57 | 58 | CGFloat cookieSize = ceilf(size.width / 6.0f); 59 | CGFloat cookiePadding = cookieSize * 2.0f; 60 | for (int i = 0; i < 3; i++) { 61 | CALayer *cookieLayer = [CALayer layer]; 62 | cookieLayer.frame = CGRectMake(cookieTerminatorCenter.x + (cookieSize + cookiePadding) * 3.0f - cookieTerminatorSize, oY - cookieSize / 2.0f, cookieSize, cookieSize); 63 | cookieLayer.backgroundColor = tintColor.CGColor; 64 | cookieLayer.anchorPoint = CGPointMake(0.5f, 0.5f); 65 | cookieLayer.opacity = 1.0f; 66 | cookieLayer.cornerRadius = cookieSize / 2.0f; 67 | 68 | CABasicAnimation *transformAnimation = [self createBasicAnimationWithKeyPath:@"transform"]; 69 | transformAnimation.duration = 1.8f; 70 | transformAnimation.beginTime = beginTime - (i * transformAnimation.duration / 3.0f); 71 | transformAnimation.fromValue = [NSValue valueWithCATransform3D:CATransform3DMakeTranslation(0.0f, 0.0f, 0.0f)]; 72 | transformAnimation.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeTranslation(-3.0f * (cookieSize + cookiePadding), 0.0f, 0.0f)]; 73 | transformAnimation.repeatCount = HUGE_VALF; 74 | transformAnimation.timingFunction = [CAMediaTimingFunction functionWithName: kCAMediaTimingFunctionLinear]; 75 | 76 | [layer addSublayer:cookieLayer]; 77 | [cookieLayer addAnimation:transformAnimation forKey:@"animation"]; 78 | } 79 | } 80 | @end 81 | -------------------------------------------------------------------------------- /YBHud/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 "DGActivityIndicatorAnimation.h" 10 | 11 | @interface DGActivityIndicatorDoubleBounceAnimation: DGActivityIndicatorAnimation 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /YBHud/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 = [self createKeyframeAnimationWithKeyPath:@"transform"]; 31 | transformAnimation.repeatCount = HUGE_VALF; 32 | transformAnimation.duration = 2.0f; 33 | transformAnimation.beginTime = beginTime - (1.0f * i); 34 | transformAnimation.keyTimes = @[@(0.0f), @(0.5f), @(1.0f)]; 35 | 36 | transformAnimation.timingFunctions = @[[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut], 37 | [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut], 38 | [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]]; 39 | 40 | transformAnimation.values = @[[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.0f, 0.0f, 0.0f)], 41 | [NSValue valueWithCATransform3D:CATransform3DMakeScale(1.0f, 1.0f, 0.0f)], 42 | [NSValue valueWithCATransform3D:CATransform3DMakeScale(0.0f, 0.0f, 0.0f)]]; 43 | 44 | [layer addSublayer:circle]; 45 | [circle addAnimation:transformAnimation forKey:@"animation"]; 46 | } 47 | 48 | } 49 | 50 | @end 51 | -------------------------------------------------------------------------------- /YBHud/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 "DGActivityIndicatorAnimation.h" 10 | 11 | @interface DGActivityIndicatorFiveDotsAnimation: DGActivityIndicatorAnimation 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /YBHud/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 = [self createKeyframeAnimationWithKeyPath:@"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.beginTime = beginTime; 53 | transformAnimation.repeatCount = HUGE_VALF; 54 | transformAnimation.duration = 1.0f; 55 | transformAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear]; 56 | 57 | [layer addSublayer:circle]; 58 | [circle addAnimation:transformAnimation forKey:@"animation"]; 59 | } 60 | 61 | for (int i = 0; i < 2; i++) { 62 | CALayer *circle = [CALayer layer]; 63 | circle.frame = CGRectMake((layer.bounds.size.width - circleSize * 5) / 2.0f + circleSize + circleSize * 2 * i, (layer.bounds.size.height - circleSize) / 2.0f, circleSize, circleSize); 64 | circle.backgroundColor = tintColor.CGColor; 65 | circle.anchorPoint = CGPointMake(0.5f, 0.5f); 66 | circle.opacity = 1.0f; 67 | circle.cornerRadius = circle.bounds.size.height / 2.0f; 68 | 69 | CATransform3D t1 = CATransform3DMakeTranslation(0.0f, 0.0f, 0.0f); 70 | t1 = CATransform3DScale(t1, 0.3f, 0.3f, 0.0f); 71 | 72 | CATransform3D t2 = CATransform3DMakeTranslation(0.0f, 2 * circleSize, 0.0f); 73 | t2 = CATransform3DScale(t2, 1.0f, 1.0f, 0.0f); 74 | 75 | CATransform3D t3 = CATransform3DMakeTranslation(0.0f, -2 * circleSize, 0.0f); 76 | t3 = CATransform3DScale(t3, 1.f, 1.0f, 0.0f); 77 | 78 | CATransform3D t4 = CATransform3DMakeTranslation(0.0f, 0.0f, 0.0f); 79 | t4 = CATransform3DScale(t4, 0.3f, 0.3f, 0.0f); 80 | 81 | CAKeyframeAnimation *transformAnimation = [self createKeyframeAnimationWithKeyPath:@"transform"]; 82 | transformAnimation.values = @[[NSValue valueWithCATransform3D:t1], 83 | [NSValue valueWithCATransform3D:t2], 84 | [NSValue valueWithCATransform3D:t3], 85 | [NSValue valueWithCATransform3D:t4]]; 86 | transformAnimation.keyTimes = @[@(0.0f), @(0.25f), @(0.75f), @(1.0f)]; 87 | transformAnimation.beginTime = beginTime; 88 | transformAnimation.repeatCount = HUGE_VALF; 89 | transformAnimation.duration = 1.0f; 90 | transformAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear]; 91 | 92 | [layer addSublayer:circle]; 93 | [circle addAnimation:transformAnimation forKey:@"animation"]; 94 | } 95 | } 96 | 97 | @end 98 | -------------------------------------------------------------------------------- /YBHud/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 "DGActivityIndicatorAnimation.h" 10 | 11 | @interface DGActivityIndicatorLineScaleAnimation: DGActivityIndicatorAnimation 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /YBHud/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 = [self createKeyframeAnimationWithKeyPath:@"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 | -------------------------------------------------------------------------------- /YBHud/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 "DGActivityIndicatorAnimation.h" 10 | 11 | @interface DGActivityIndicatorLineScalePartyAnimation: DGActivityIndicatorAnimation 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /YBHud/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 = [self createKeyframeAnimationWithKeyPath:@"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 | -------------------------------------------------------------------------------- /YBHud/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 "DGActivityIndicatorAnimation.h" 10 | 11 | @interface DGActivityIndicatorLineScalePulseOutAnimation: DGActivityIndicatorAnimation 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /YBHud/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 = [self createKeyframeAnimationWithKeyPath:@"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 | -------------------------------------------------------------------------------- /YBHud/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 "DGActivityIndicatorAnimation.h" 10 | 11 | @interface DGActivityIndicatorLineScalePulseOutRapidAnimation: DGActivityIndicatorAnimation 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /YBHud/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 = [self createKeyframeAnimationWithKeyPath:@"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 | -------------------------------------------------------------------------------- /YBHud/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 "DGActivityIndicatorAnimation.h" 10 | 11 | @interface DGActivityIndicatorNineDotsAnimation: DGActivityIndicatorAnimation 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /YBHud/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 = [self createKeyframeAnimationWithKeyPath:@"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 = [self createKeyframeAnimationWithKeyPath:@"opacity"]; 46 | opacityAnimation.values = @[@(0.5f), @(1.0f), @(0.5f)]; 47 | 48 | CAAnimationGroup *animationGroup = [self createAnimationGroup];; 49 | animationGroup.beginTime = beginTime; 50 | animationGroup.repeatCount = HUGE_VALF; 51 | animationGroup.duration = [durations[i] doubleValue]; 52 | animationGroup.animations = @[transformAnimation, opacityAnimation]; 53 | animationGroup.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear]; 54 | animationGroup.timeOffset = [timeOffsets[i] doubleValue]; 55 | 56 | [layer addSublayer:circle]; 57 | [circle addAnimation:animationGroup forKey:@"animation"]; 58 | } 59 | } 60 | 61 | @end 62 | -------------------------------------------------------------------------------- /YBHud/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 "DGActivityIndicatorAnimation.h" 10 | 11 | @interface DGActivityIndicatorRotatingSandglassAnimation: DGActivityIndicatorAnimation 12 | 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /YBHud/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 = [self createKeyframeAnimationWithKeyPath:@"transform"]; 35 | transformAnimation.repeatCount = HUGE_VALF; 36 | transformAnimation.duration = 0.8f; 37 | transformAnimation.beginTime = beginTime; 38 | transformAnimation.keyTimes = @[@(0.0f), @(1.0f / 3.0f), @(2.0f / 3.0f), @(1.0)]; 39 | 40 | transformAnimation.timingFunctions = @[[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear], 41 | [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear], 42 | [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear], 43 | [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear]]; 44 | 45 | CATransform3D t1 = CATransform3DMakeTranslation((1.0f - 2.0f * i) * (size.width - 2.0f * circleSize), 0.0f, 0.0f); 46 | 47 | 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); 48 | 49 | CATransform3D t3 = CATransform3DMakeTranslation(0.0f, 0.0f, 0.0f); 50 | 51 | 52 | transformAnimation.values = @[[NSValue valueWithCATransform3D:CATransform3DIdentity], 53 | [NSValue valueWithCATransform3D:t1], 54 | [NSValue valueWithCATransform3D:t2], 55 | [NSValue valueWithCATransform3D:t3]]; 56 | 57 | [layer addSublayer:circle]; 58 | [circle addAnimation:transformAnimation forKey:@"animation"]; 59 | } 60 | } 61 | @end 62 | -------------------------------------------------------------------------------- /YBHud/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 "DGActivityIndicatorAnimation.h" 10 | 11 | @interface DGActivityIndicatorRotatingSquaresAnimation: DGActivityIndicatorAnimation 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /YBHud/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 = [self createKeyframeAnimationWithKeyPath:@"transform"]; 34 | transformAnimation.duration = 1.6f; 35 | transformAnimation.beginTime = beginTime - (i * transformAnimation.duration / 2.0f); 36 | transformAnimation.repeatCount = HUGE_VALF; 37 | 38 | transformAnimation.keyTimes = @[@(0.0f), @(0.25f), @(0.50f), @(0.75f), @(1.0f)]; 39 | transformAnimation.timingFunctions = @[[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut], 40 | [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut], 41 | [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut], 42 | [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut], 43 | [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]]; 44 | 45 | CATransform3D t1 = CATransform3DMakeTranslation(size.width - squareSize, 0.0f, 0.0f); 46 | t1 = CATransform3DRotate(t1, degreesToRadians(-90.0f), 0.0f, 0.0f, 1.0f); 47 | t1 = CATransform3DScale(t1, 0.5f, 0.5f, 1.0f); 48 | 49 | CATransform3D t2 = CATransform3DMakeTranslation(size.width - squareSize, size.height - squareSize, 0.0f); 50 | t2 = CATransform3DRotate(t2, degreesToRadians(-180.0f), 0.0f, 0.0f, 1.0f); 51 | t2 = CATransform3DScale(t2, 1.0, 1.0, 1.0f); 52 | 53 | CATransform3D t3 = CATransform3DMakeTranslation(0.0f, size.height - squareSize, 0.0f); 54 | t3 = CATransform3DRotate(t3, degreesToRadians(-270.0f), 0.0f, 0.0f, 1.0f); 55 | t3 = CATransform3DScale(t3, 0.5f, 0.5f, 1.0f); 56 | 57 | CATransform3D t4 = CATransform3DMakeTranslation(0.0f, 0.0f, 0.0f); 58 | t4 = CATransform3DRotate(t4, degreesToRadians(-360.0f), 0.0f, 0.0f, 1.0f); 59 | t4 = CATransform3DScale(t4, 1.0, 1.0, 1.0f); 60 | 61 | transformAnimation.values = @[[NSValue valueWithCATransform3D:CATransform3DIdentity], 62 | [NSValue valueWithCATransform3D:t1], 63 | [NSValue valueWithCATransform3D:t2], 64 | [NSValue valueWithCATransform3D:t3], 65 | [NSValue valueWithCATransform3D:t4]]; 66 | 67 | [layer addSublayer:square]; 68 | [square addAnimation:transformAnimation forKey:@"animation"]; 69 | } 70 | } 71 | 72 | @end 73 | -------------------------------------------------------------------------------- /YBHud/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 "DGActivityIndicatorAnimation.h" 10 | 11 | @interface DGActivityIndicatorRotatingTrigonAnimation: DGActivityIndicatorAnimation 12 | 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /YBHud/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 = [self createKeyframeAnimationWithKeyPath:@"transform"]; 42 | transformAnimation.repeatCount = HUGE_VALF; 43 | transformAnimation.duration = 2.0f; 44 | transformAnimation.beginTime = beginTime - (i * transformAnimation.duration / 3.0f);; 45 | transformAnimation.keyTimes = @[@(0.0f), @(1.0f / 3.0f), @(2.0f / 3.0f), @(1.0)]; 46 | 47 | transformAnimation.timingFunctions = @[[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut], 48 | [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut], 49 | [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut], 50 | [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]]; 51 | 52 | CATransform3D t1 = CATransform3DMakeTranslation(pointB.x - pointA.x, pointB.y - pointA.y, 0.0f); 53 | 54 | CATransform3D t2 = CATransform3DMakeTranslation(pointC.x - pointA.x, pointC.y - pointA.y, 0.0f); 55 | 56 | CATransform3D t3 = CATransform3DMakeTranslation(0.0f, 0.0f, 0.0f); 57 | 58 | transformAnimation.values = @[[NSValue valueWithCATransform3D:CATransform3DIdentity], 59 | [NSValue valueWithCATransform3D:t1], 60 | [NSValue valueWithCATransform3D:t2], 61 | [NSValue valueWithCATransform3D:t3]]; 62 | 63 | [layer addSublayer:circle]; 64 | [circle addAnimation:transformAnimation forKey:@"animation"]; 65 | } 66 | } 67 | @end 68 | -------------------------------------------------------------------------------- /YBHud/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 "DGActivityIndicatorAnimation.h" 10 | 11 | @interface DGActivityIndicatorThreeDotsAnimation : DGActivityIndicatorAnimation 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /YBHud/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 = [self createKeyframeAnimationWithKeyPath:@"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 = [self createKeyframeAnimationWithKeyPath:@"opacity"]; 41 | 42 | opacityAnimation.values = @[@(0.25f), @(1.0f)]; 43 | 44 | CAAnimationGroup *animationGroup = [self createAnimationGroup];; 45 | 46 | animationGroup.autoreverses = YES; 47 | animationGroup.beginTime = beginTime; 48 | animationGroup.repeatCount = HUGE_VALF; 49 | animationGroup.duration = duration; 50 | animationGroup.animations = @[tranformAnimation, opacityAnimation]; 51 | animationGroup.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear]; 52 | 53 | [layer addSublayer:circle]; 54 | [circle addAnimation:animationGroup forKey:@"animation"]; 55 | } 56 | } 57 | 58 | @end 59 | -------------------------------------------------------------------------------- /YBHud/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 "DGActivityIndicatorAnimation.h" 10 | 11 | @interface DGActivityIndicatorTriangleSkewSpinAnimation: DGActivityIndicatorAnimation 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /YBHud/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 = [self createKeyframeAnimationWithKeyPath:@"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 = [self createKeyframeAnimationWithKeyPath:@"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 = [self createAnimationGroup];; 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 | -------------------------------------------------------------------------------- /YBHud/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 "DGActivityIndicatorAnimation.h" 10 | 11 | @interface DGActivityIndicatorTriplePulseAnimation: DGActivityIndicatorAnimation 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /YBHud/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 = [self createBasicAnimationWithKeyPath:@"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 = [self createBasicAnimationWithKeyPath:@"opacity"]; 35 | opacityAnimation.fromValue = @(0.8f); 36 | opacityAnimation.toValue = @(0.0f); 37 | 38 | CAAnimationGroup *animationGroup = [self createAnimationGroup];; 39 | animationGroup.beginTime = beginTime + i * 0.2f; 40 | animationGroup.repeatCount = HUGE_VALF; 41 | animationGroup.duration = 1.2f; 42 | animationGroup.animations = @[transformAnimation, opacityAnimation]; 43 | 44 | [layer addSublayer:circle]; 45 | [circle addAnimation:animationGroup forKey:@"animation"]; 46 | } 47 | } 48 | 49 | @end 50 | -------------------------------------------------------------------------------- /YBHud/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 "DGActivityIndicatorAnimation.h" 9 | 10 | @interface DGActivityIndicatorTripleRingsAnimation: DGActivityIndicatorAnimation 11 | 12 | @end 13 | -------------------------------------------------------------------------------- /YBHud/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 = [self createBasicAnimationWithKeyPath:@"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 = [self createBasicAnimationWithKeyPath:@"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 = [self createAnimationGroup];; 45 | animationGroup.beginTime = beginTime + i * 0.4f; 46 | animationGroup.repeatCount = HUGE_VALF; 47 | animationGroup.duration = 2.0f; 48 | animationGroup.animations = @[transformAnimation, opacityAnimation]; 49 | 50 | [layer addSublayer:circle]; 51 | [circle addAnimation:animationGroup forKey:@"animation"]; 52 | } 53 | } 54 | @end 55 | -------------------------------------------------------------------------------- /YBHud/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 "DGActivityIndicatorAnimation.h" 10 | 11 | @interface DGActivityIndicatorTwoDotsAnimation: DGActivityIndicatorAnimation 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /YBHud/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 = [self createKeyframeAnimationWithKeyPath:@"transform"]; 29 | transformAnimation.repeatCount = HUGE_VALF; 30 | transformAnimation.duration = 1.8f; 31 | transformAnimation.beginTime = beginTime - (transformAnimation.duration / 2.0f * i); 32 | transformAnimation.keyTimes = @[@(0.0), @(0.5), @(1.0)]; 33 | 34 | transformAnimation.timingFunctions = @[[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut], 35 | [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut], 36 | [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]]; 37 | 38 | transformAnimation.values = @[[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.0f, 0.0f, 0.0f)], 39 | [NSValue valueWithCATransform3D:CATransform3DMakeScale(1.0f, 1.0f, 0.0f)], 40 | [NSValue valueWithCATransform3D:CATransform3DMakeScale(0.0f, 0.0f, 0.0f)]]; 41 | 42 | [layer addSublayer:circle]; 43 | [circle addAnimation:transformAnimation forKey:@"animation"]; 44 | } 45 | } 46 | 47 | @end 48 | -------------------------------------------------------------------------------- /YBHud/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 -------------------------------------------------------------------------------- /YBHud/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 | -------------------------------------------------------------------------------- /YBHud/DGActivityIndicatorView/DGActivityIndicatorView.m: -------------------------------------------------------------------------------- 1 | // 2 | // DGActivityIndicatorView.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 "DGActivityIndicatorView.h" 10 | 11 | #import "DGActivityIndicatorNineDotsAnimation.h" 12 | #import "DGActivityIndicatorTriplePulseAnimation.h" 13 | #import "DGActivityIndicatorFiveDotsAnimation.h" 14 | #import "DGActivityIndicatorRotatingSquaresAnimation.h" 15 | #import "DGActivityIndicatorDoubleBounceAnimation.h" 16 | #import "DGActivityIndicatorTwoDotsAnimation.h" 17 | #import "DGActivityIndicatorThreeDotsAnimation.h" 18 | #import "DGActivityIndicatorBallPulseAnimation.h" 19 | #import "DGActivityIndicatorBallClipRotateAnimation.h" 20 | #import "DGActivityIndicatorBallClipRotatePulseAnimation.h" 21 | #import "DGActivityIndicatorBallClipRotateMultipleAnimation.h" 22 | #import "DGActivityIndicatorBallRotateAnimation.h" 23 | #import "DGActivityIndicatorBallZigZagAnimation.h" 24 | #import "DGActivityIndicatorBallZigZagDeflectAnimation.h" 25 | #import "DGActivityIndicatorBallTrianglePathAnimation.h" 26 | #import "DGActivityIndicatorBallScaleAnimation.h" 27 | #import "DGActivityIndicatorLineScaleAnimation.h" 28 | #import "DGActivityIndicatorLineScalePartyAnimation.h" 29 | #import "DGActivityIndicatorBallScaleMultipleAnimation.h" 30 | #import "DGActivityIndicatorBallPulseSyncAnimation.h" 31 | #import "DGActivityIndicatorBallBeatAnimation.h" 32 | #import "DGActivityIndicatorLineScalePulseOutAnimation.h" 33 | #import "DGActivityIndicatorLineScalePulseOutRapidAnimation.h" 34 | #import "DGActivityIndicatorBallScaleRippleAnimation.h" 35 | #import "DGActivityIndicatorBallScaleRippleMultipleAnimation.h" 36 | #import "DGActivityIndicatorTriangleSkewSpinAnimation.h" 37 | #import "DGActivityIndicatorBallGridBeatAnimation.h" 38 | #import "DGActivityIndicatorBallGridPulseAnimation.h" 39 | #import "DGActivityIndicatorRotatingSandglassAnimation.h" 40 | #import "DGActivityIndicatorRotatingTrigonAnimation.h" 41 | #import "DGActivityIndicatorTripleRingsAnimation.h" 42 | #import "DGActivityIndicatorCookieTerminatorAnimation.h" 43 | #import "DGActivityIndicatorBallSpinFadeLoader.h" 44 | 45 | static const CGFloat kDGActivityIndicatorDefaultSize = 40.0f; 46 | 47 | @interface DGActivityIndicatorView () { 48 | CALayer *_animationLayer; 49 | } 50 | 51 | @end 52 | 53 | @implementation DGActivityIndicatorView 54 | 55 | #pragma mark - 56 | #pragma mark Constructors 57 | 58 | - (instancetype)initWithCoder:(NSCoder *)aDecoder { 59 | self = [super initWithCoder:aDecoder]; 60 | if (self) { 61 | _tintColor = [UIColor whiteColor]; 62 | _size = kDGActivityIndicatorDefaultSize; 63 | [self commonInit]; 64 | } 65 | return self; 66 | } 67 | 68 | - (id)initWithType:(DGActivityIndicatorAnimationType)type { 69 | return [self initWithType:type tintColor:[UIColor whiteColor] size:kDGActivityIndicatorDefaultSize]; 70 | } 71 | 72 | - (id)initWithType:(DGActivityIndicatorAnimationType)type tintColor:(UIColor *)tintColor { 73 | return [self initWithType:type tintColor:tintColor size:kDGActivityIndicatorDefaultSize]; 74 | } 75 | 76 | - (id)initWithType:(DGActivityIndicatorAnimationType)type tintColor:(UIColor *)tintColor size:(CGFloat)size { 77 | self = [super init]; 78 | if (self) { 79 | _type = type; 80 | _size = size; 81 | _tintColor = tintColor; 82 | [self commonInit]; 83 | } 84 | return self; 85 | } 86 | 87 | #pragma mark - 88 | #pragma mark Methods 89 | 90 | - (void)commonInit { 91 | self.userInteractionEnabled = NO; 92 | self.hidden = YES; 93 | 94 | _animationLayer = [[CALayer alloc] init]; 95 | [self.layer addSublayer:_animationLayer]; 96 | 97 | [self setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal]; 98 | [self setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisVertical]; 99 | } 100 | 101 | - (void)setupAnimation { 102 | _animationLayer.sublayers = nil; 103 | 104 | id animation = [DGActivityIndicatorView activityIndicatorAnimationForAnimationType:_type]; 105 | 106 | if ([animation respondsToSelector:@selector(setupAnimationInLayer:withSize:tintColor:)]) { 107 | [animation setupAnimationInLayer:_animationLayer withSize:CGSizeMake(_size, _size) tintColor:_tintColor]; 108 | _animationLayer.speed = 0.0f; 109 | } 110 | } 111 | 112 | - (void)startAnimating { 113 | if (!_animationLayer.sublayers) { 114 | [self setupAnimation]; 115 | } 116 | self.hidden = NO; 117 | _animationLayer.speed = 1.0f; 118 | _animating = YES; 119 | } 120 | 121 | - (void)stopAnimating { 122 | _animationLayer.speed = 0.0f; 123 | _animating = NO; 124 | self.hidden = YES; 125 | } 126 | 127 | #pragma mark - 128 | #pragma mark Setters 129 | 130 | - (void)setType:(DGActivityIndicatorAnimationType)type { 131 | if (_type != type) { 132 | _type = type; 133 | 134 | [self setupAnimation]; 135 | } 136 | } 137 | 138 | - (void)setSize:(CGFloat)size { 139 | if (_size != size) { 140 | _size = size; 141 | 142 | [self setupAnimation]; 143 | [self invalidateIntrinsicContentSize]; 144 | } 145 | } 146 | 147 | - (void)setTintColor:(UIColor *)tintColor { 148 | if (![_tintColor isEqual:tintColor]) { 149 | _tintColor = tintColor; 150 | 151 | CGColorRef tintColorRef = tintColor.CGColor; 152 | for (CALayer *sublayer in _animationLayer.sublayers) { 153 | sublayer.backgroundColor = tintColorRef; 154 | 155 | if ([sublayer isKindOfClass:[CAShapeLayer class]]) { 156 | CAShapeLayer *shapeLayer = [[CAShapeLayer alloc] init]; 157 | shapeLayer.strokeColor = tintColorRef; 158 | shapeLayer.fillColor = tintColorRef; 159 | } 160 | } 161 | } 162 | } 163 | 164 | #pragma mark - 165 | #pragma mark Getters 166 | 167 | + (id)activityIndicatorAnimationForAnimationType:(DGActivityIndicatorAnimationType)type { 168 | switch (type) { 169 | case DGActivityIndicatorAnimationTypeNineDots: 170 | return [[DGActivityIndicatorNineDotsAnimation alloc] init]; 171 | case DGActivityIndicatorAnimationTypeTriplePulse: 172 | return [[DGActivityIndicatorTriplePulseAnimation alloc] init]; 173 | case DGActivityIndicatorAnimationTypeFiveDots: 174 | return [[DGActivityIndicatorFiveDotsAnimation alloc] init]; 175 | case DGActivityIndicatorAnimationTypeRotatingSquares: 176 | return [[DGActivityIndicatorRotatingSquaresAnimation alloc] init]; 177 | case DGActivityIndicatorAnimationTypeDoubleBounce: 178 | return [[DGActivityIndicatorDoubleBounceAnimation alloc] init]; 179 | case DGActivityIndicatorAnimationTypeTwoDots: 180 | return [[DGActivityIndicatorTwoDotsAnimation alloc] init]; 181 | case DGActivityIndicatorAnimationTypeThreeDots: 182 | return [[DGActivityIndicatorThreeDotsAnimation alloc] init]; 183 | case DGActivityIndicatorAnimationTypeBallPulse: 184 | return [[DGActivityIndicatorBallPulseAnimation alloc] init]; 185 | case DGActivityIndicatorAnimationTypeBallClipRotate: 186 | return [[DGActivityIndicatorBallClipRotateAnimation alloc] init]; 187 | case DGActivityIndicatorAnimationTypeBallClipRotatePulse: 188 | return [[DGActivityIndicatorBallClipRotatePulseAnimation alloc] init]; 189 | case DGActivityIndicatorAnimationTypeBallClipRotateMultiple: 190 | return [[DGActivityIndicatorBallClipRotateMultipleAnimation alloc] init]; 191 | case DGActivityIndicatorAnimationTypeBallRotate: 192 | return [[DGActivityIndicatorBallRotateAnimation alloc] init]; 193 | case DGActivityIndicatorAnimationTypeBallZigZag: 194 | return [[DGActivityIndicatorBallZigZagAnimation alloc] init]; 195 | case DGActivityIndicatorAnimationTypeBallZigZagDeflect: 196 | return [[DGActivityIndicatorBallZigZagDeflectAnimation alloc] init]; 197 | case DGActivityIndicatorAnimationTypeBallTrianglePath: 198 | return [[DGActivityIndicatorBallTrianglePathAnimation alloc] init]; 199 | case DGActivityIndicatorAnimationTypeBallScale: 200 | return [[DGActivityIndicatorBallScaleAnimation alloc] init]; 201 | case DGActivityIndicatorAnimationTypeLineScale: 202 | return [[DGActivityIndicatorLineScaleAnimation alloc] init]; 203 | case DGActivityIndicatorAnimationTypeLineScaleParty: 204 | return [[DGActivityIndicatorLineScalePartyAnimation alloc] init]; 205 | case DGActivityIndicatorAnimationTypeBallScaleMultiple: 206 | return [[DGActivityIndicatorBallScaleMultipleAnimation alloc] init]; 207 | case DGActivityIndicatorAnimationTypeBallPulseSync: 208 | return [[DGActivityIndicatorBallPulseSyncAnimation alloc] init]; 209 | case DGActivityIndicatorAnimationTypeBallBeat: 210 | return [[DGActivityIndicatorBallBeatAnimation alloc] init]; 211 | case DGActivityIndicatorAnimationTypeLineScalePulseOut: 212 | return [[DGActivityIndicatorLineScalePulseOutAnimation alloc] init]; 213 | case DGActivityIndicatorAnimationTypeLineScalePulseOutRapid: 214 | return [[DGActivityIndicatorLineScalePulseOutRapidAnimation alloc] init]; 215 | case DGActivityIndicatorAnimationTypeBallScaleRipple: 216 | return [[DGActivityIndicatorBallScaleRippleAnimation alloc] init]; 217 | case DGActivityIndicatorAnimationTypeBallScaleRippleMultiple: 218 | return [[DGActivityIndicatorBallScaleRippleMultipleAnimation alloc] init]; 219 | case DGActivityIndicatorAnimationTypeTriangleSkewSpin: 220 | return [[DGActivityIndicatorTriangleSkewSpinAnimation alloc] init]; 221 | case DGActivityIndicatorAnimationTypeBallGridBeat: 222 | return [[DGActivityIndicatorBallGridBeatAnimation alloc] init]; 223 | case DGActivityIndicatorAnimationTypeBallGridPulse: 224 | return [[DGActivityIndicatorBallGridPulseAnimation alloc] init]; 225 | case DGActivityIndicatorAnimationTypeRotatingSandglass: 226 | return [[DGActivityIndicatorRotatingSandglassAnimation alloc]init]; 227 | case DGActivityIndicatorAnimationTypeRotatingTrigons: 228 | return [[DGActivityIndicatorRotatingTrigonAnimation alloc]init]; 229 | case DGActivityIndicatorAnimationTypeTripleRings: 230 | return [[DGActivityIndicatorTripleRingsAnimation alloc]init]; 231 | case DGActivityIndicatorAnimationTypeCookieTerminator: 232 | return [[DGActivityIndicatorCookieTerminatorAnimation alloc]init]; 233 | case DGActivityIndicatorAnimationTypeBallSpinFadeLoader: 234 | return [[DGActivityIndicatorBallSpinFadeLoader alloc] init]; 235 | } 236 | return nil; 237 | } 238 | 239 | #pragma mark - 240 | #pragma mark Layout 241 | 242 | - (void)layoutSubviews { 243 | [super layoutSubviews]; 244 | 245 | _animationLayer.frame = self.bounds; 246 | 247 | BOOL animating = _animating; 248 | 249 | if (animating) 250 | [self stopAnimating]; 251 | 252 | [self setupAnimation]; 253 | 254 | if (animating) 255 | [self startAnimating]; 256 | } 257 | 258 | - (CGSize)intrinsicContentSize { 259 | return CGSizeMake(_size, _size); 260 | } 261 | 262 | @end 263 | -------------------------------------------------------------------------------- /YBHud/Images/YBHud_1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YahyaBagia/YBHud/9048131581671c1baa1fcb92c912d8eb5c18bd75/YBHud/Images/YBHud_1.gif -------------------------------------------------------------------------------- /YBHud/Images/YBHud_2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YahyaBagia/YBHud/9048131581671c1baa1fcb92c912d8eb5c18bd75/YBHud/Images/YBHud_2.gif -------------------------------------------------------------------------------- /YBHud/Images/YBHud_3.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YahyaBagia/YBHud/9048131581671c1baa1fcb92c912d8eb5c18bd75/YBHud/Images/YBHud_3.gif -------------------------------------------------------------------------------- /YBHud/Images/YBHud_4.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YahyaBagia/YBHud/9048131581671c1baa1fcb92c912d8eb5c18bd75/YBHud/Images/YBHud_4.gif -------------------------------------------------------------------------------- /YBHud/Images/YBHud_5.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YahyaBagia/YBHud/9048131581671c1baa1fcb92c912d8eb5c18bd75/YBHud/Images/YBHud_5.gif -------------------------------------------------------------------------------- /YBHud/Images/YBHud_Logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YahyaBagia/YBHud/9048131581671c1baa1fcb92c912d8eb5c18bd75/YBHud/Images/YBHud_Logo.png -------------------------------------------------------------------------------- /YBHud/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIRequiredDeviceCapabilities 26 | 27 | armv7 28 | 29 | UISupportedInterfaceOrientations 30 | 31 | UIInterfaceOrientationPortrait 32 | UIInterfaceOrientationLandscapeLeft 33 | UIInterfaceOrientationLandscapeRight 34 | 35 | UISupportedInterfaceOrientations~ipad 36 | 37 | UIInterfaceOrientationPortrait 38 | UIInterfaceOrientationPortraitUpsideDown 39 | UIInterfaceOrientationLandscapeLeft 40 | UIInterfaceOrientationLandscapeRight 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /YBHud/ViewController/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // YBHud 4 | // 5 | // Created by Yahya on 03/02/17. 6 | // Copyright © 2017 yahya. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /YBHud/ViewController/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // YBHud 4 | // 5 | // Created by Yahya on 03/02/17. 6 | // Copyright © 2017 yahya. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "CustomCell.h" 11 | #import "YBHud.h" 12 | 13 | #define kIdentifier @"Identifier" 14 | 15 | @interface ViewController () 16 | { 17 | YBHud *hud; 18 | NSArray *types; 19 | NSArray *typeNames; 20 | } 21 | @property (weak, nonatomic) IBOutlet UITableView *tableView; 22 | @end 23 | 24 | @implementation ViewController 25 | 26 | - (void)viewDidLoad { 27 | [super viewDidLoad]; 28 | 29 | self.view.backgroundColor = [UIColor colorWithRed:237/255.0f green:85/255.0f blue:101/255.0f alpha:1.0f]; 30 | 31 | types = @[@(DGActivityIndicatorAnimationTypeNineDots), 32 | @(DGActivityIndicatorAnimationTypeTriplePulse), 33 | @(DGActivityIndicatorAnimationTypeFiveDots), 34 | @(DGActivityIndicatorAnimationTypeRotatingSquares), 35 | @(DGActivityIndicatorAnimationTypeDoubleBounce), 36 | @(DGActivityIndicatorAnimationTypeTwoDots), 37 | @(DGActivityIndicatorAnimationTypeThreeDots), 38 | @(DGActivityIndicatorAnimationTypeBallPulse), 39 | @(DGActivityIndicatorAnimationTypeBallClipRotate), 40 | @(DGActivityIndicatorAnimationTypeBallClipRotatePulse), 41 | @(DGActivityIndicatorAnimationTypeBallClipRotateMultiple), 42 | @(DGActivityIndicatorAnimationTypeBallRotate), 43 | @(DGActivityIndicatorAnimationTypeBallZigZag), 44 | @(DGActivityIndicatorAnimationTypeBallZigZagDeflect), 45 | @(DGActivityIndicatorAnimationTypeBallTrianglePath), 46 | @(DGActivityIndicatorAnimationTypeBallScale), 47 | @(DGActivityIndicatorAnimationTypeLineScale), 48 | @(DGActivityIndicatorAnimationTypeLineScaleParty), 49 | @(DGActivityIndicatorAnimationTypeBallScaleMultiple), 50 | @(DGActivityIndicatorAnimationTypeBallPulseSync), 51 | @(DGActivityIndicatorAnimationTypeBallBeat), 52 | @(DGActivityIndicatorAnimationTypeLineScalePulseOut), 53 | @(DGActivityIndicatorAnimationTypeLineScalePulseOutRapid), 54 | @(DGActivityIndicatorAnimationTypeBallScaleRipple), 55 | @(DGActivityIndicatorAnimationTypeBallScaleRippleMultiple), 56 | @(DGActivityIndicatorAnimationTypeTriangleSkewSpin), 57 | @(DGActivityIndicatorAnimationTypeBallGridBeat), 58 | @(DGActivityIndicatorAnimationTypeBallGridPulse), 59 | @(DGActivityIndicatorAnimationTypeRotatingSandglass), 60 | @(DGActivityIndicatorAnimationTypeRotatingTrigons), 61 | @(DGActivityIndicatorAnimationTypeTripleRings), 62 | @(DGActivityIndicatorAnimationTypeCookieTerminator), 63 | @(DGActivityIndicatorAnimationTypeBallSpinFadeLoader)]; 64 | 65 | typeNames = @[@"NineDots", 66 | @"TriplePulse", 67 | @"FiveDots", 68 | @"RotatingSquares", 69 | @"DoubleBounce", 70 | @"TwoDots", 71 | @"ThreeDots", 72 | @"BallPulse", 73 | @"BallClipRotate", 74 | @"BallClipRotatePulse", 75 | @"BallClipRotateMultiple", 76 | @"BallRotate", 77 | @"BallZigZag", 78 | @"BallZigZagDeflect", 79 | @"BallTrianglePath", 80 | @"BallScale", 81 | @"LineScale", 82 | @"LineScaleParty", 83 | @"BallScaleMultiple", 84 | @"BallPulseSync", 85 | @"BallBeat", 86 | @"LineScalePulseOut", 87 | @"LineScalePulseOutRapid", 88 | @"BallScaleRipple", 89 | @"BallScaleRippleMultiple", 90 | @"TriangleSkewSpin", 91 | @"BallGridBeat", 92 | @"BallGridPulse", 93 | @"RotatingSandglass", 94 | @"RotatingTrigons", 95 | @"TripleRings", 96 | @"CookieTerminator", 97 | @"BallSpinFadeLoader"]; 98 | typeNames = [typeNames sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)]; 99 | 100 | [_tableView registerNib:[UINib nibWithNibName:@"CustomCell" bundle:nil] forCellReuseIdentifier:kIdentifier]; 101 | 102 | } 103 | 104 | - (void)didReceiveMemoryWarning { 105 | [super didReceiveMemoryWarning]; 106 | // Dispose of any resources that can be recreated. 107 | } 108 | 109 | -(void)dismissHud{ 110 | [hud dismissAnimated:YES]; 111 | } 112 | 113 | #pragma mark - TableView Methods 114 | 115 | -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ 116 | CustomCell *cell; 117 | 118 | if (cell == nil) { 119 | NSArray *nib=[[NSBundle mainBundle] loadNibNamed:@"CustomCell" owner:self options:nil]; 120 | cell = [nib objectAtIndex:0]; 121 | } 122 | 123 | cell.lblTitle.text = typeNames[indexPath.row]; 124 | 125 | DGActivityIndicatorView *activityIndicatorView = [[DGActivityIndicatorView alloc] initWithType:(DGActivityIndicatorAnimationType)[types[indexPath.row] integerValue] tintColor:[UIColor whiteColor]]; 126 | 127 | activityIndicatorView.frame = CGRectMake(0, 0, 64, 68.5714); 128 | [cell.subView addSubview:activityIndicatorView]; 129 | [activityIndicatorView startAnimating]; 130 | 131 | return cell; 132 | } 133 | 134 | -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ 135 | hud = [[YBHud alloc]initWithHudType:indexPath.row andText:typeNames[indexPath.row]]; 136 | 137 | //Optional Tint Color (Indicator Color) 138 | //hud.tintColor = [UIColor blackColor]; 139 | 140 | //Optional User Interaction (User can interact with background views while HUD is displayed) 141 | //hud.UserInteractionDisabled = YES; 142 | 143 | //Optional HUD Color 144 | //hud.hudColor = [UIColor yellowColor]; 145 | 146 | //Optional Dim Amount of HUD 147 | //hud.dimAmount = 0.3; 148 | 149 | //Display HUD 150 | [hud showInView:self.view animated:YES]; 151 | 152 | 153 | //Dismissing HUD After 5 Seconds 154 | [self performSelector:@selector(dismissHud) withObject:nil afterDelay:3.0]; 155 | } 156 | 157 | -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ 158 | return 70; 159 | } 160 | 161 | -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ 162 | return [types count]; 163 | } 164 | 165 | -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ 166 | return 1; 167 | } 168 | 169 | #pragma mark - 170 | 171 | @end 172 | -------------------------------------------------------------------------------- /YBHud/ViewController/ViewController.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /YBHud/YBHud/YBHud.h: -------------------------------------------------------------------------------- 1 | // 2 | // YBHud.h 3 | // YBHud 4 | // 5 | // Created by Yahya on 03/02/17. 6 | // Copyright © 2017 yahya. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "DGActivityIndicatorView.h" 11 | 12 | @interface YBHud : NSObject 13 | 14 | //Public Methods 15 | -(id)initWithHudType:(DGActivityIndicatorAnimationType)HUDType andText:(NSString *)text; 16 | 17 | -(void)showInView:(UIView *)view; 18 | -(void)showInView:(UIView *)view animated:(BOOL)shouldAnimate; 19 | -(void)dismiss; 20 | -(void)dismissAnimated:(BOOL)shouldAnimate; 21 | 22 | //Public Properties 23 | @property (nonatomic, retain) UIColor *tintColor; // Tint Color of the Loader and Text (Optional) (Default : White) 24 | @property (nonatomic, retain) UIColor *hudColor; // Background color of HUD (Optional) (Default : Black) 25 | @property (nonatomic) CGFloat dimAmount; // Dim Amount of HUD (Optional) (Default : 0.7) 26 | @property (nonatomic, retain) NSString *text; 27 | @property (nonatomic, retain) UIFont *textFont; 28 | 29 | //USER INTERACTION 30 | @property (nonatomic) BOOL UserInteractionDisabled; 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /YBHud/YBHud/YBHud.m: -------------------------------------------------------------------------------- 1 | // 2 | // YBHud.m 3 | // YBHud 4 | // 5 | // Created by Yahya on 03/02/17. 6 | // Copyright © 2017 yahya. All rights reserved. 7 | // 8 | 9 | #import "YBHud.h" 10 | #import "DGActivityIndicatorView.h" 11 | 12 | #define kAnimateDuration 0.25 13 | 14 | #define kIndicatorWidth 64 15 | #define kIndicatorHeight 68.5714 16 | 17 | #define kTransformScaleDown CGAffineTransformScale(CGAffineTransformIdentity, 0.001, 0.001) 18 | #define kTransformScaleOriginal CGAffineTransformScale(CGAffineTransformIdentity, 1.0, 1.0) 19 | 20 | @implementation YBHud 21 | { 22 | DGActivityIndicatorView *indicator; 23 | UILabel *textLabel; 24 | UIView *blockView; 25 | 26 | } 27 | 28 | -(id)initWithHudType:(DGActivityIndicatorAnimationType)HUDType andText:(NSString *)text{ 29 | if (self=[super init]){ 30 | 31 | _tintColor = [UIColor whiteColor]; 32 | _textFont = [UIFont boldSystemFontOfSize:18]; 33 | _text = text; 34 | 35 | indicator = [[DGActivityIndicatorView alloc] 36 | initWithType : HUDType 37 | tintColor : _tintColor]; 38 | } 39 | return self; 40 | } 41 | 42 | -(void)showInView:(UIView *)view{ 43 | [self showInView:view animated:NO]; 44 | } 45 | 46 | -(void)showInView:(UIView *)view animated:(BOOL)shouldAnimate{ 47 | 48 | blockView = [[UIView alloc] initWithFrame:[view bounds]]; 49 | 50 | if(_UserInteractionDisabled) blockView.userInteractionEnabled = NO; 51 | 52 | UIColor *hudColor = (_hudColor == nil) ? [UIColor blackColor] : _hudColor; 53 | if(_dimAmount == 0){ _dimAmount = 0.7; } 54 | 55 | hudColor = [hudColor colorWithAlphaComponent:_dimAmount]; 56 | 57 | [blockView setBackgroundColor:hudColor]; 58 | 59 | if(_tintColor != nil){ indicator.tintColor = _tintColor; } 60 | 61 | indicator.frame = CGRectMake(0, 0, kIndicatorWidth, kIndicatorHeight); 62 | indicator.center = blockView.center; 63 | [indicator startAnimating]; 64 | [blockView addSubview:indicator]; 65 | 66 | if(_text.length > 0){ 67 | CGRect labelFrame = CGRectMake(8, kIndicatorHeight + 4, blockView.frame.size.width - 16, 0); 68 | textLabel = [[UILabel alloc] initWithFrame:labelFrame]; 69 | textLabel.numberOfLines = 0; 70 | textLabel.lineBreakMode = NSLineBreakByWordWrapping; 71 | textLabel.textAlignment = NSTextAlignmentCenter; 72 | textLabel.textColor = _tintColor; 73 | textLabel.font = _textFont; 74 | textLabel.text = _text; 75 | [blockView addSubview:textLabel]; 76 | } 77 | 78 | if(shouldAnimate){ 79 | 80 | indicator.transform = kTransformScaleDown; 81 | if(textLabel){ 82 | textLabel.transform = kTransformScaleDown; 83 | } 84 | 85 | blockView.alpha=0.3; 86 | __weak __typeof(self)weakSelf = self; 87 | [UIView animateWithDuration:kAnimateDuration 88 | animations:^{ 89 | __strong __typeof(weakSelf)strongSelf = weakSelf; 90 | if (strongSelf!=nil) { 91 | strongSelf->indicator.transform = kTransformScaleOriginal; 92 | if (strongSelf->textLabel){ 93 | strongSelf->textLabel.transform = kTransformScaleOriginal; 94 | } 95 | strongSelf->blockView.alpha = 1.0; 96 | [view addSubview:strongSelf->blockView]; 97 | } 98 | } completion:^(BOOL finished) { }]; 99 | } 100 | 101 | 102 | else{ 103 | [view addSubview:blockView]; 104 | } 105 | 106 | /*Add Constraints*/ 107 | blockView.translatesAutoresizingMaskIntoConstraints = false; 108 | 109 | NSLayoutConstraint *blockTrailing =[NSLayoutConstraint 110 | constraintWithItem:blockView 111 | attribute:NSLayoutAttributeTrailing 112 | relatedBy:NSLayoutRelationEqual 113 | toItem:view 114 | attribute:NSLayoutAttributeTrailing 115 | multiplier:1.0f 116 | constant:0.f]; 117 | 118 | NSLayoutConstraint *blockLeading = [NSLayoutConstraint 119 | constraintWithItem:blockView 120 | attribute:NSLayoutAttributeLeading 121 | relatedBy:NSLayoutRelationEqual 122 | toItem:view 123 | attribute:NSLayoutAttributeLeading 124 | multiplier:1.0f 125 | constant:0.f]; 126 | 127 | NSLayoutConstraint *blockBottom = [NSLayoutConstraint 128 | constraintWithItem:blockView 129 | attribute:NSLayoutAttributeBottom 130 | relatedBy:NSLayoutRelationEqual 131 | toItem:view 132 | attribute:NSLayoutAttributeBottom 133 | multiplier:1.0f 134 | constant:0.f]; 135 | 136 | NSLayoutConstraint *blockTop = [NSLayoutConstraint 137 | constraintWithItem: blockView 138 | attribute: NSLayoutAttributeTop 139 | relatedBy: NSLayoutRelationEqual 140 | toItem: view 141 | attribute: NSLayoutAttributeTop 142 | multiplier: 1.0f 143 | constant: 0.f]; 144 | 145 | [view addConstraints:@[blockTrailing, blockLeading, blockBottom, blockTop]]; 146 | 147 | 148 | indicator.translatesAutoresizingMaskIntoConstraints = false; 149 | 150 | NSLayoutConstraint *indicatorWidth = [NSLayoutConstraint 151 | constraintWithItem:indicator 152 | attribute:NSLayoutAttributeWidth 153 | relatedBy:NSLayoutRelationEqual 154 | toItem:nil 155 | attribute:NSLayoutAttributeNotAnAttribute 156 | multiplier:1.0f 157 | constant:kIndicatorWidth]; 158 | 159 | NSLayoutConstraint *indicatorHeight = [NSLayoutConstraint 160 | constraintWithItem:indicator 161 | attribute:NSLayoutAttributeHeight 162 | relatedBy:NSLayoutRelationEqual 163 | toItem:nil 164 | attribute:NSLayoutAttributeNotAnAttribute 165 | multiplier:1.0f 166 | constant:kIndicatorHeight]; 167 | 168 | [[indicator.centerXAnchor constraintEqualToAnchor:blockView.centerXAnchor] setActive:YES]; 169 | 170 | [[indicator.centerYAnchor constraintEqualToAnchor:blockView.centerYAnchor] setActive:YES]; 171 | 172 | [indicator addConstraints:@[indicatorWidth, indicatorHeight]]; 173 | 174 | 175 | if(textLabel){ 176 | 177 | textLabel.translatesAutoresizingMaskIntoConstraints = false; 178 | 179 | NSLayoutConstraint *labelTop = [NSLayoutConstraint 180 | constraintWithItem:textLabel 181 | attribute:NSLayoutAttributeTop 182 | relatedBy:NSLayoutRelationEqual 183 | toItem:indicator 184 | attribute:NSLayoutAttributeTop 185 | multiplier:1.0f 186 | constant:kIndicatorHeight + 4]; 187 | 188 | NSLayoutConstraint *labelTrailing = [NSLayoutConstraint 189 | constraintWithItem:textLabel 190 | attribute:NSLayoutAttributeTrailing 191 | relatedBy:NSLayoutRelationEqual 192 | toItem:blockView 193 | attribute:NSLayoutAttributeTrailing 194 | multiplier:1.0f constant:-8 ]; 195 | 196 | NSLayoutConstraint *labelLeading = [NSLayoutConstraint 197 | constraintWithItem:textLabel 198 | attribute:NSLayoutAttributeLeading 199 | relatedBy:NSLayoutRelationEqual 200 | toItem:blockView 201 | attribute:NSLayoutAttributeLeading 202 | multiplier:1.0f 203 | constant:8]; 204 | 205 | 206 | [[textLabel.centerXAnchor constraintEqualToAnchor:blockView.centerXAnchor] setActive:YES]; 207 | 208 | [blockView addConstraints:@[labelTop, labelTrailing, labelLeading ]]; 209 | 210 | } 211 | 212 | } 213 | 214 | -(void)dismiss{ 215 | [self dismissAnimated:NO]; 216 | } 217 | 218 | -(void)dismissAnimated:(BOOL)shouldAnimate{ 219 | if(shouldAnimate){ 220 | __weak __typeof(self)weakSelf = self; 221 | [UIView animateWithDuration:kAnimateDuration 222 | animations:^{ 223 | __strong __typeof(weakSelf)strongSelf = weakSelf; 224 | if (strongSelf!=nil) { 225 | strongSelf->indicator.transform = kTransformScaleDown; 226 | if(strongSelf->textLabel){ 227 | strongSelf->textLabel.transform = kTransformScaleDown; 228 | } 229 | strongSelf->blockView.alpha = 0.0; 230 | } 231 | } 232 | completion:^(BOOL finished){ 233 | __strong __typeof(weakSelf)strongSelf = weakSelf; 234 | if (strongSelf!=nil) { 235 | [strongSelf->blockView removeFromSuperview]; 236 | } 237 | }]; 238 | }else{ 239 | [blockView removeFromSuperview]; 240 | } 241 | } 242 | 243 | @end 244 | -------------------------------------------------------------------------------- /YBHud/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // YBHud 4 | // 5 | // Created by Yahya on 03/02/17. 6 | // Copyright © 2017 yahya. 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 | --------------------------------------------------------------------------------