├── README.md ├── Screenshot ├── BuyMeACoffee.png ├── LoadingCapsuleSpacing.gif ├── LoadingCircleColors.gif ├── LoadingCircleFlip.gif ├── LoadingCircleGradual.gif ├── LoadingCircleOpacity.gif └── LoadingCubeOffset.gif ├── SwiftUI-Loading-Animation.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist └── xcuserdata │ └── adam.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist └── SwiftUI-Loading-Animation ├── Assets.xcassets ├── AccentColor.colorset │ └── Contents.json ├── AppIcon.appiconset │ └── Contents.json ├── Contents.json └── cat.imageset │ ├── Contents.json │ └── cat.png ├── CapsuleSpacing.swift ├── CircleColors.swift ├── CircleFlip.swift ├── CircleGradual.swift ├── CircleOpacity.swift ├── CubeOffset.swift ├── Info.plist ├── Preview Content └── Preview Assets.xcassets │ └── Contents.json └── SwiftUI_Loading_AnimationApp.swift /README.md: -------------------------------------------------------------------------------- 1 | # SwiftUI Loading Animation 2 | 3 | My goal with this project is to get iOS developers to use Creative Loading Animation without building them from scratch. 💯 SwiftUI NO External Packages. 4 | 5 | ## Your Coffee allows me to excel, Gracias ☕ 6 | 7 | Buy Me A Coffee 8 | 9 | ### Loading: Circle Opacity | Circle Colors | Capsule Spacing. 10 |
11 | Loading Circle Opacity 13 | Loading Circle Colors 15 | Loading Capsule Spacing 17 |
18 | 19 | ### Loading: Circle Flip | Cube Offset | Circle Gradual. 20 |
21 | Loading Circle flip 23 | Loading Cube Offset 25 | Circle Gradual 27 |
28 | 29 | ## Usage 30 | I made the SwiftUI animation slower to make your eyes recognize the animation. 31 | 32 | In reality it is not. To customize the animation. 33 | 34 | ✅ 35 | - Change the duration, delay & time Interval 36 | - Change the size of the shape 37 | 38 | 🚫 39 | - Don't touch the state ( unless you have experience in animation ) 40 | ## Contributing 41 | 42 | Contributions are always welcome! 43 | 44 | -------------------------------------------------------------------------------- /Screenshot/BuyMeACoffee.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sirkif/SwiftUI-Loading-Animation/9292eb7c608a340ad0e2c21879e080505d0685d6/Screenshot/BuyMeACoffee.png -------------------------------------------------------------------------------- /Screenshot/LoadingCapsuleSpacing.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sirkif/SwiftUI-Loading-Animation/9292eb7c608a340ad0e2c21879e080505d0685d6/Screenshot/LoadingCapsuleSpacing.gif -------------------------------------------------------------------------------- /Screenshot/LoadingCircleColors.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sirkif/SwiftUI-Loading-Animation/9292eb7c608a340ad0e2c21879e080505d0685d6/Screenshot/LoadingCircleColors.gif -------------------------------------------------------------------------------- /Screenshot/LoadingCircleFlip.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sirkif/SwiftUI-Loading-Animation/9292eb7c608a340ad0e2c21879e080505d0685d6/Screenshot/LoadingCircleFlip.gif -------------------------------------------------------------------------------- /Screenshot/LoadingCircleGradual.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sirkif/SwiftUI-Loading-Animation/9292eb7c608a340ad0e2c21879e080505d0685d6/Screenshot/LoadingCircleGradual.gif -------------------------------------------------------------------------------- /Screenshot/LoadingCircleOpacity.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sirkif/SwiftUI-Loading-Animation/9292eb7c608a340ad0e2c21879e080505d0685d6/Screenshot/LoadingCircleOpacity.gif -------------------------------------------------------------------------------- /Screenshot/LoadingCubeOffset.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sirkif/SwiftUI-Loading-Animation/9292eb7c608a340ad0e2c21879e080505d0685d6/Screenshot/LoadingCubeOffset.gif -------------------------------------------------------------------------------- /SwiftUI-Loading-Animation.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 50; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 661933AA26581FD900098AAD /* BuyMeACoffee.png in Resources */ = {isa = PBXBuildFile; fileRef = 661933A926581FD900098AAD /* BuyMeACoffee.png */; }; 11 | 66287DFB2659222300462AC2 /* CubeOffset.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66287DFA2659222300462AC2 /* CubeOffset.swift */; }; 12 | 663C5DB7265342AA000C83DC /* CapsuleSpacing.swift in Sources */ = {isa = PBXBuildFile; fileRef = 663C5DB6265342AA000C83DC /* CapsuleSpacing.swift */; }; 13 | 664347232651BD1700A26419 /* SwiftUI_Loading_AnimationApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 664347222651BD1700A26419 /* SwiftUI_Loading_AnimationApp.swift */; }; 14 | 664347272651BD1800A26419 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 664347262651BD1800A26419 /* Assets.xcassets */; }; 15 | 6643472A2651BD1800A26419 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 664347292651BD1800A26419 /* Preview Assets.xcassets */; }; 16 | 664347322651BD9D00A26419 /* CircleColors.swift in Sources */ = {isa = PBXBuildFile; fileRef = 664347312651BD9D00A26419 /* CircleColors.swift */; }; 17 | 667E0BCC265B0BC50002CE17 /* CircleGradual.swift in Sources */ = {isa = PBXBuildFile; fileRef = 667E0BCB265B0BC50002CE17 /* CircleGradual.swift */; }; 18 | 6682A2262657E2980095D978 /* LoadingCapsuleSpacing.gif in Resources */ = {isa = PBXBuildFile; fileRef = 6682A2252657E2980095D978 /* LoadingCapsuleSpacing.gif */; }; 19 | 6682A2282657E2A00095D978 /* LoadingCircleColors.gif in Resources */ = {isa = PBXBuildFile; fileRef = 6682A2272657E2A00095D978 /* LoadingCircleColors.gif */; }; 20 | 6682A22A2657E2A90095D978 /* LoadingCircleOpacity.gif in Resources */ = {isa = PBXBuildFile; fileRef = 6682A2292657E2A90095D978 /* LoadingCircleOpacity.gif */; }; 21 | 66870E95265BC2D2004D69BB /* CircleFlip.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66870E94265BC2D2004D69BB /* CircleFlip.swift */; }; 22 | 66B2FACC2655D1C300E473B9 /* CircleOpacity.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66B2FACB2655D1C300E473B9 /* CircleOpacity.swift */; }; 23 | 66BBBA5B265C3E2A001CF27E /* LoadingCubeOffset.gif in Resources */ = {isa = PBXBuildFile; fileRef = 66BBBA5A265C3E2A001CF27E /* LoadingCubeOffset.gif */; }; 24 | 66BBBA5F265C3E3B001CF27E /* LoadingCircleFlip.gif in Resources */ = {isa = PBXBuildFile; fileRef = 66BBBA5E265C3E3B001CF27E /* LoadingCircleFlip.gif */; }; 25 | 66BBBA63265C4233001CF27E /* LoadingCircleGradual.gif in Resources */ = {isa = PBXBuildFile; fileRef = 66BBBA62265C4233001CF27E /* LoadingCircleGradual.gif */; }; 26 | /* End PBXBuildFile section */ 27 | 28 | /* Begin PBXFileReference section */ 29 | 661933A926581FD900098AAD /* BuyMeACoffee.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = BuyMeACoffee.png; sourceTree = ""; }; 30 | 66287DFA2659222300462AC2 /* CubeOffset.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CubeOffset.swift; sourceTree = ""; }; 31 | 663C5DB6265342AA000C83DC /* CapsuleSpacing.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CapsuleSpacing.swift; sourceTree = ""; }; 32 | 6643471F2651BD1700A26419 /* SwiftUI-Loading-Animation.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "SwiftUI-Loading-Animation.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 33 | 664347222651BD1700A26419 /* SwiftUI_Loading_AnimationApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftUI_Loading_AnimationApp.swift; sourceTree = ""; }; 34 | 664347262651BD1800A26419 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 35 | 664347292651BD1800A26419 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; 36 | 6643472B2651BD1800A26419 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 37 | 664347312651BD9D00A26419 /* CircleColors.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CircleColors.swift; sourceTree = ""; }; 38 | 667E0BCB265B0BC50002CE17 /* CircleGradual.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CircleGradual.swift; sourceTree = ""; }; 39 | 6682A2252657E2980095D978 /* LoadingCapsuleSpacing.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; path = LoadingCapsuleSpacing.gif; sourceTree = ""; }; 40 | 6682A2272657E2A00095D978 /* LoadingCircleColors.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; path = LoadingCircleColors.gif; sourceTree = ""; }; 41 | 6682A2292657E2A90095D978 /* LoadingCircleOpacity.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; path = LoadingCircleOpacity.gif; sourceTree = ""; }; 42 | 66870E94265BC2D2004D69BB /* CircleFlip.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CircleFlip.swift; sourceTree = ""; }; 43 | 66B2FACB2655D1C300E473B9 /* CircleOpacity.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CircleOpacity.swift; sourceTree = ""; }; 44 | 66BBBA5A265C3E2A001CF27E /* LoadingCubeOffset.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; path = LoadingCubeOffset.gif; sourceTree = ""; }; 45 | 66BBBA5E265C3E3B001CF27E /* LoadingCircleFlip.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; path = LoadingCircleFlip.gif; sourceTree = ""; }; 46 | 66BBBA62265C4233001CF27E /* LoadingCircleGradual.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; path = LoadingCircleGradual.gif; sourceTree = ""; }; 47 | /* End PBXFileReference section */ 48 | 49 | /* Begin PBXFrameworksBuildPhase section */ 50 | 6643471C2651BD1600A26419 /* Frameworks */ = { 51 | isa = PBXFrameworksBuildPhase; 52 | buildActionMask = 2147483647; 53 | files = ( 54 | ); 55 | runOnlyForDeploymentPostprocessing = 0; 56 | }; 57 | /* End PBXFrameworksBuildPhase section */ 58 | 59 | /* Begin PBXGroup section */ 60 | 664347162651BD1600A26419 = { 61 | isa = PBXGroup; 62 | children = ( 63 | 664347212651BD1700A26419 /* SwiftUI-Loading-Animation */, 64 | 66C9CC5E265845F900A22B69 /* Screenshot */, 65 | 664347202651BD1700A26419 /* Products */, 66 | ); 67 | sourceTree = ""; 68 | }; 69 | 664347202651BD1700A26419 /* Products */ = { 70 | isa = PBXGroup; 71 | children = ( 72 | 6643471F2651BD1700A26419 /* SwiftUI-Loading-Animation.app */, 73 | ); 74 | name = Products; 75 | sourceTree = ""; 76 | }; 77 | 664347212651BD1700A26419 /* SwiftUI-Loading-Animation */ = { 78 | isa = PBXGroup; 79 | children = ( 80 | 664347222651BD1700A26419 /* SwiftUI_Loading_AnimationApp.swift */, 81 | 663C5DB6265342AA000C83DC /* CapsuleSpacing.swift */, 82 | 664347312651BD9D00A26419 /* CircleColors.swift */, 83 | 66B2FACB2655D1C300E473B9 /* CircleOpacity.swift */, 84 | 66287DFA2659222300462AC2 /* CubeOffset.swift */, 85 | 667E0BCB265B0BC50002CE17 /* CircleGradual.swift */, 86 | 66870E94265BC2D2004D69BB /* CircleFlip.swift */, 87 | 664347262651BD1800A26419 /* Assets.xcassets */, 88 | 6643472B2651BD1800A26419 /* Info.plist */, 89 | 664347282651BD1800A26419 /* Preview Content */, 90 | ); 91 | path = "SwiftUI-Loading-Animation"; 92 | sourceTree = ""; 93 | }; 94 | 664347282651BD1800A26419 /* Preview Content */ = { 95 | isa = PBXGroup; 96 | children = ( 97 | 664347292651BD1800A26419 /* Preview Assets.xcassets */, 98 | ); 99 | path = "Preview Content"; 100 | sourceTree = ""; 101 | }; 102 | 66C9CC5E265845F900A22B69 /* Screenshot */ = { 103 | isa = PBXGroup; 104 | children = ( 105 | 6682A2252657E2980095D978 /* LoadingCapsuleSpacing.gif */, 106 | 6682A2272657E2A00095D978 /* LoadingCircleColors.gif */, 107 | 6682A2292657E2A90095D978 /* LoadingCircleOpacity.gif */, 108 | 66BBBA5A265C3E2A001CF27E /* LoadingCubeOffset.gif */, 109 | 66BBBA62265C4233001CF27E /* LoadingCircleGradual.gif */, 110 | 66BBBA5E265C3E3B001CF27E /* LoadingCircleFlip.gif */, 111 | 661933A926581FD900098AAD /* BuyMeACoffee.png */, 112 | ); 113 | path = Screenshot; 114 | sourceTree = ""; 115 | }; 116 | /* End PBXGroup section */ 117 | 118 | /* Begin PBXNativeTarget section */ 119 | 6643471E2651BD1600A26419 /* SwiftUI-Loading-Animation */ = { 120 | isa = PBXNativeTarget; 121 | buildConfigurationList = 6643472E2651BD1800A26419 /* Build configuration list for PBXNativeTarget "SwiftUI-Loading-Animation" */; 122 | buildPhases = ( 123 | 6643471B2651BD1600A26419 /* Sources */, 124 | 6643471C2651BD1600A26419 /* Frameworks */, 125 | 6643471D2651BD1600A26419 /* Resources */, 126 | ); 127 | buildRules = ( 128 | ); 129 | dependencies = ( 130 | ); 131 | name = "SwiftUI-Loading-Animation"; 132 | productName = "SwiftUI-Loading-Animation"; 133 | productReference = 6643471F2651BD1700A26419 /* SwiftUI-Loading-Animation.app */; 134 | productType = "com.apple.product-type.application"; 135 | }; 136 | /* End PBXNativeTarget section */ 137 | 138 | /* Begin PBXProject section */ 139 | 664347172651BD1600A26419 /* Project object */ = { 140 | isa = PBXProject; 141 | attributes = { 142 | LastSwiftUpdateCheck = 1250; 143 | LastUpgradeCheck = 1250; 144 | TargetAttributes = { 145 | 6643471E2651BD1600A26419 = { 146 | CreatedOnToolsVersion = 12.5; 147 | }; 148 | }; 149 | }; 150 | buildConfigurationList = 6643471A2651BD1600A26419 /* Build configuration list for PBXProject "SwiftUI-Loading-Animation" */; 151 | compatibilityVersion = "Xcode 9.3"; 152 | developmentRegion = en; 153 | hasScannedForEncodings = 0; 154 | knownRegions = ( 155 | en, 156 | Base, 157 | ); 158 | mainGroup = 664347162651BD1600A26419; 159 | productRefGroup = 664347202651BD1700A26419 /* Products */; 160 | projectDirPath = ""; 161 | projectRoot = ""; 162 | targets = ( 163 | 6643471E2651BD1600A26419 /* SwiftUI-Loading-Animation */, 164 | ); 165 | }; 166 | /* End PBXProject section */ 167 | 168 | /* Begin PBXResourcesBuildPhase section */ 169 | 6643471D2651BD1600A26419 /* Resources */ = { 170 | isa = PBXResourcesBuildPhase; 171 | buildActionMask = 2147483647; 172 | files = ( 173 | 66BBBA63265C4233001CF27E /* LoadingCircleGradual.gif in Resources */, 174 | 6643472A2651BD1800A26419 /* Preview Assets.xcassets in Resources */, 175 | 6682A2282657E2A00095D978 /* LoadingCircleColors.gif in Resources */, 176 | 66BBBA5F265C3E3B001CF27E /* LoadingCircleFlip.gif in Resources */, 177 | 66BBBA5B265C3E2A001CF27E /* LoadingCubeOffset.gif in Resources */, 178 | 664347272651BD1800A26419 /* Assets.xcassets in Resources */, 179 | 6682A2262657E2980095D978 /* LoadingCapsuleSpacing.gif in Resources */, 180 | 661933AA26581FD900098AAD /* BuyMeACoffee.png in Resources */, 181 | 6682A22A2657E2A90095D978 /* LoadingCircleOpacity.gif in Resources */, 182 | ); 183 | runOnlyForDeploymentPostprocessing = 0; 184 | }; 185 | /* End PBXResourcesBuildPhase section */ 186 | 187 | /* Begin PBXSourcesBuildPhase section */ 188 | 6643471B2651BD1600A26419 /* Sources */ = { 189 | isa = PBXSourcesBuildPhase; 190 | buildActionMask = 2147483647; 191 | files = ( 192 | 66870E95265BC2D2004D69BB /* CircleFlip.swift in Sources */, 193 | 663C5DB7265342AA000C83DC /* CapsuleSpacing.swift in Sources */, 194 | 664347322651BD9D00A26419 /* CircleColors.swift in Sources */, 195 | 66287DFB2659222300462AC2 /* CubeOffset.swift in Sources */, 196 | 66B2FACC2655D1C300E473B9 /* CircleOpacity.swift in Sources */, 197 | 664347232651BD1700A26419 /* SwiftUI_Loading_AnimationApp.swift in Sources */, 198 | 667E0BCC265B0BC50002CE17 /* CircleGradual.swift in Sources */, 199 | ); 200 | runOnlyForDeploymentPostprocessing = 0; 201 | }; 202 | /* End PBXSourcesBuildPhase section */ 203 | 204 | /* Begin XCBuildConfiguration section */ 205 | 6643472C2651BD1800A26419 /* Debug */ = { 206 | isa = XCBuildConfiguration; 207 | buildSettings = { 208 | ALWAYS_SEARCH_USER_PATHS = NO; 209 | CLANG_ANALYZER_NONNULL = YES; 210 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 211 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 212 | CLANG_CXX_LIBRARY = "libc++"; 213 | CLANG_ENABLE_MODULES = YES; 214 | CLANG_ENABLE_OBJC_ARC = YES; 215 | CLANG_ENABLE_OBJC_WEAK = YES; 216 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 217 | CLANG_WARN_BOOL_CONVERSION = YES; 218 | CLANG_WARN_COMMA = YES; 219 | CLANG_WARN_CONSTANT_CONVERSION = YES; 220 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 221 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 222 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 223 | CLANG_WARN_EMPTY_BODY = YES; 224 | CLANG_WARN_ENUM_CONVERSION = YES; 225 | CLANG_WARN_INFINITE_RECURSION = YES; 226 | CLANG_WARN_INT_CONVERSION = YES; 227 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 228 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 229 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 230 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 231 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 232 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 233 | CLANG_WARN_STRICT_PROTOTYPES = YES; 234 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 235 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 236 | CLANG_WARN_UNREACHABLE_CODE = YES; 237 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 238 | COPY_PHASE_STRIP = NO; 239 | DEBUG_INFORMATION_FORMAT = dwarf; 240 | ENABLE_STRICT_OBJC_MSGSEND = YES; 241 | ENABLE_TESTABILITY = YES; 242 | GCC_C_LANGUAGE_STANDARD = gnu11; 243 | GCC_DYNAMIC_NO_PIC = NO; 244 | GCC_NO_COMMON_BLOCKS = YES; 245 | GCC_OPTIMIZATION_LEVEL = 0; 246 | GCC_PREPROCESSOR_DEFINITIONS = ( 247 | "DEBUG=1", 248 | "$(inherited)", 249 | ); 250 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 251 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 252 | GCC_WARN_UNDECLARED_SELECTOR = YES; 253 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 254 | GCC_WARN_UNUSED_FUNCTION = YES; 255 | GCC_WARN_UNUSED_VARIABLE = YES; 256 | IPHONEOS_DEPLOYMENT_TARGET = 14.5; 257 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 258 | MTL_FAST_MATH = YES; 259 | ONLY_ACTIVE_ARCH = YES; 260 | SDKROOT = iphoneos; 261 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 262 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 263 | }; 264 | name = Debug; 265 | }; 266 | 6643472D2651BD1800A26419 /* Release */ = { 267 | isa = XCBuildConfiguration; 268 | buildSettings = { 269 | ALWAYS_SEARCH_USER_PATHS = NO; 270 | CLANG_ANALYZER_NONNULL = YES; 271 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 272 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 273 | CLANG_CXX_LIBRARY = "libc++"; 274 | CLANG_ENABLE_MODULES = YES; 275 | CLANG_ENABLE_OBJC_ARC = YES; 276 | CLANG_ENABLE_OBJC_WEAK = YES; 277 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 278 | CLANG_WARN_BOOL_CONVERSION = YES; 279 | CLANG_WARN_COMMA = YES; 280 | CLANG_WARN_CONSTANT_CONVERSION = YES; 281 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 282 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 283 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 284 | CLANG_WARN_EMPTY_BODY = YES; 285 | CLANG_WARN_ENUM_CONVERSION = YES; 286 | CLANG_WARN_INFINITE_RECURSION = YES; 287 | CLANG_WARN_INT_CONVERSION = YES; 288 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 289 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 290 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 291 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 292 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 293 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 294 | CLANG_WARN_STRICT_PROTOTYPES = YES; 295 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 296 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 297 | CLANG_WARN_UNREACHABLE_CODE = YES; 298 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 299 | COPY_PHASE_STRIP = NO; 300 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 301 | ENABLE_NS_ASSERTIONS = NO; 302 | ENABLE_STRICT_OBJC_MSGSEND = YES; 303 | GCC_C_LANGUAGE_STANDARD = gnu11; 304 | GCC_NO_COMMON_BLOCKS = YES; 305 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 306 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 307 | GCC_WARN_UNDECLARED_SELECTOR = YES; 308 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 309 | GCC_WARN_UNUSED_FUNCTION = YES; 310 | GCC_WARN_UNUSED_VARIABLE = YES; 311 | IPHONEOS_DEPLOYMENT_TARGET = 14.5; 312 | MTL_ENABLE_DEBUG_INFO = NO; 313 | MTL_FAST_MATH = YES; 314 | SDKROOT = iphoneos; 315 | SWIFT_COMPILATION_MODE = wholemodule; 316 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 317 | VALIDATE_PRODUCT = YES; 318 | }; 319 | name = Release; 320 | }; 321 | 6643472F2651BD1800A26419 /* Debug */ = { 322 | isa = XCBuildConfiguration; 323 | buildSettings = { 324 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 325 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 326 | CODE_SIGN_STYLE = Automatic; 327 | DEVELOPMENT_ASSET_PATHS = "\"SwiftUI-Loading-Animation/Preview Content\""; 328 | DEVELOPMENT_TEAM = 335ZCP6WMN; 329 | ENABLE_PREVIEWS = YES; 330 | INFOPLIST_FILE = "SwiftUI-Loading-Animation/Info.plist"; 331 | IPHONEOS_DEPLOYMENT_TARGET = 14.0; 332 | LD_RUNPATH_SEARCH_PATHS = ( 333 | "$(inherited)", 334 | "@executable_path/Frameworks", 335 | ); 336 | PRODUCT_BUNDLE_IDENTIFIER = "com.SwiftUI-Loading-Animation"; 337 | PRODUCT_NAME = "$(TARGET_NAME)"; 338 | SWIFT_VERSION = 5.0; 339 | TARGETED_DEVICE_FAMILY = "1,2"; 340 | }; 341 | name = Debug; 342 | }; 343 | 664347302651BD1800A26419 /* Release */ = { 344 | isa = XCBuildConfiguration; 345 | buildSettings = { 346 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 347 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 348 | CODE_SIGN_STYLE = Automatic; 349 | DEVELOPMENT_ASSET_PATHS = "\"SwiftUI-Loading-Animation/Preview Content\""; 350 | DEVELOPMENT_TEAM = 335ZCP6WMN; 351 | ENABLE_PREVIEWS = YES; 352 | INFOPLIST_FILE = "SwiftUI-Loading-Animation/Info.plist"; 353 | IPHONEOS_DEPLOYMENT_TARGET = 14.0; 354 | LD_RUNPATH_SEARCH_PATHS = ( 355 | "$(inherited)", 356 | "@executable_path/Frameworks", 357 | ); 358 | PRODUCT_BUNDLE_IDENTIFIER = "com.SwiftUI-Loading-Animation"; 359 | PRODUCT_NAME = "$(TARGET_NAME)"; 360 | SWIFT_VERSION = 5.0; 361 | TARGETED_DEVICE_FAMILY = "1,2"; 362 | }; 363 | name = Release; 364 | }; 365 | /* End XCBuildConfiguration section */ 366 | 367 | /* Begin XCConfigurationList section */ 368 | 6643471A2651BD1600A26419 /* Build configuration list for PBXProject "SwiftUI-Loading-Animation" */ = { 369 | isa = XCConfigurationList; 370 | buildConfigurations = ( 371 | 6643472C2651BD1800A26419 /* Debug */, 372 | 6643472D2651BD1800A26419 /* Release */, 373 | ); 374 | defaultConfigurationIsVisible = 0; 375 | defaultConfigurationName = Release; 376 | }; 377 | 6643472E2651BD1800A26419 /* Build configuration list for PBXNativeTarget "SwiftUI-Loading-Animation" */ = { 378 | isa = XCConfigurationList; 379 | buildConfigurations = ( 380 | 6643472F2651BD1800A26419 /* Debug */, 381 | 664347302651BD1800A26419 /* Release */, 382 | ); 383 | defaultConfigurationIsVisible = 0; 384 | defaultConfigurationName = Release; 385 | }; 386 | /* End XCConfigurationList section */ 387 | }; 388 | rootObject = 664347172651BD1600A26419 /* Project object */; 389 | } 390 | -------------------------------------------------------------------------------- /SwiftUI-Loading-Animation.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /SwiftUI-Loading-Animation.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /SwiftUI-Loading-Animation.xcodeproj/xcuserdata/adam.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | SwiftUI-Loading-Animation.xcscheme_^#shared#^_ 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /SwiftUI-Loading-Animation/Assets.xcassets/AccentColor.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "idiom" : "universal" 5 | } 6 | ], 7 | "info" : { 8 | "author" : "xcode", 9 | "version" : 1 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /SwiftUI-Loading-Animation/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "scale" : "2x", 6 | "size" : "20x20" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "scale" : "3x", 11 | "size" : "20x20" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "scale" : "2x", 16 | "size" : "29x29" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "scale" : "3x", 21 | "size" : "29x29" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "scale" : "2x", 26 | "size" : "40x40" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "scale" : "3x", 31 | "size" : "40x40" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "scale" : "2x", 36 | "size" : "60x60" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "scale" : "3x", 41 | "size" : "60x60" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "scale" : "1x", 46 | "size" : "20x20" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "scale" : "2x", 51 | "size" : "20x20" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "scale" : "1x", 56 | "size" : "29x29" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "scale" : "2x", 61 | "size" : "29x29" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "scale" : "1x", 66 | "size" : "40x40" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "scale" : "2x", 71 | "size" : "40x40" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "scale" : "1x", 76 | "size" : "76x76" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "scale" : "2x", 81 | "size" : "76x76" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "scale" : "2x", 86 | "size" : "83.5x83.5" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "scale" : "1x", 91 | "size" : "1024x1024" 92 | } 93 | ], 94 | "info" : { 95 | "author" : "xcode", 96 | "version" : 1 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /SwiftUI-Loading-Animation/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /SwiftUI-Loading-Animation/Assets.xcassets/cat.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "filename" : "cat.png", 5 | "idiom" : "universal", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "author" : "xcode", 19 | "version" : 1 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /SwiftUI-Loading-Animation/Assets.xcassets/cat.imageset/cat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sirkif/SwiftUI-Loading-Animation/9292eb7c608a340ad0e2c21879e080505d0685d6/SwiftUI-Loading-Animation/Assets.xcassets/cat.imageset/cat.png -------------------------------------------------------------------------------- /SwiftUI-Loading-Animation/CapsuleSpacing.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CapsuleSpacing.swift 3 | // SwiftUI-Loading-Animation 4 | // 5 | // Created by Adam on 5/18/21. 6 | // 7 | 8 | import SwiftUI 9 | 10 | struct CapsuleSpacing: View { 11 | 12 | @State private var spacingAnimation = false 13 | 14 | var body: some View { 15 | 16 | HStack(spacing: spacingAnimation ? CGFloat(15) : CGFloat(5)) { 17 | 18 | Capsule(style: .continuous) 19 | .fill(Color(#colorLiteral(red: 0.02352941176, green: 0.8392156863, blue: 0.6274509804, alpha: 1))) 20 | .frame(width: 10, height: 60) 21 | 22 | Capsule(style: .continuous) 23 | .fill(Color(#colorLiteral(red: 1, green: 0.8196078431, blue: 0.4, alpha: 1))) 24 | .frame(width: 10, height: 40) 25 | 26 | Capsule(style: .continuous) 27 | .fill(Color(#colorLiteral(red: 0.937254902, green: 0.2784313725, blue: 0.4352941176, alpha: 1))) 28 | .frame(width: 10, height: 60) 29 | 30 | Capsule(style: .continuous) 31 | .fill(Color(#colorLiteral(red: 1, green: 0.8196078431, blue: 0.4, alpha: 1))) 32 | .frame(width: 10, height: 40) 33 | 34 | Capsule(style: .continuous) 35 | .fill(Color(#colorLiteral(red: 0.02352941176, green: 0.8392156863, blue: 0.6274509804, alpha: 1))) 36 | .frame(width: 10, height: 60) 37 | } 38 | .animation(Animation.easeInOut(duration: 1).repeatForever(autoreverses: true)) 39 | .onAppear { 40 | spacingAnimation.toggle() 41 | } 42 | } 43 | } 44 | 45 | struct CapsuleSpacing_Previews: PreviewProvider { 46 | static var previews: some View { 47 | CapsuleSpacing() 48 | .preferredColorScheme(.dark) 49 | } 50 | } 51 | 52 | -------------------------------------------------------------------------------- /SwiftUI-Loading-Animation/CircleColors.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CircleColors.swift 3 | // SwiftUI-Loading-Animation 4 | // 5 | // Created by Adam on 5/16/21. 6 | // 7 | 8 | import SwiftUI 9 | 10 | struct CircleColors: View { 11 | 12 | @State private var loadingAnimation = 0 13 | 14 | var body: some View { 15 | 16 | ZStack{ 17 | 18 | Circle() 19 | .frame(width: 10, height: 10, alignment: .center) 20 | .foregroundColor(Color(#colorLiteral(red: 0.9647058824, green: 0.9647058824, blue: 0.9647058824, alpha: 1))) 21 | .offset(y: -90) 22 | .rotationEffect(.degrees(Double(loadingAnimation))) 23 | .animation(.easeInOut(duration: 1).delay(1).repeatForever(autoreverses: false)) 24 | 25 | Circle() 26 | .frame(width: 20, height: 20, alignment: .center) 27 | .foregroundColor(Color(#colorLiteral(red: 0.7137254902, green: 0.7882352941, blue: 0.9411764706, alpha: 1))) 28 | .offset(y: -90) 29 | .rotationEffect(.degrees(Double(loadingAnimation))) 30 | .animation(.easeInOut(duration: 1.1).delay(0.9).repeatForever(autoreverses: false)) 31 | 32 | Circle() 33 | .frame(width: 30, height: 30, alignment: .center) 34 | .foregroundColor(Color(#colorLiteral(red: 1, green: 0.8980392157, blue: 0.8862745098, alpha: 1))) 35 | .offset(y: -90) 36 | .rotationEffect(.degrees(Double(loadingAnimation))) 37 | .animation(.easeInOut(duration: 1.2).delay(0.8).repeatForever(autoreverses: false)) 38 | 39 | Circle() 40 | .frame(width: 35, height: 35, alignment: .center) 41 | .foregroundColor(Color(#colorLiteral(red: 0.9607843137, green: 0.6705882353, blue: 0.7882352941, alpha: 1))) 42 | .offset(y: -90) 43 | .rotationEffect(.degrees(Double(loadingAnimation))) 44 | .animation(.easeInOut(duration: 1.3).delay(0.7).repeatForever(autoreverses: false)) 45 | 46 | Circle() 47 | .frame(width: 40, height: 40, alignment: .center) 48 | .foregroundColor(Color(#colorLiteral(red: 0.9137254902, green: 0.231372549, blue: 0.5058823529, alpha: 1))) 49 | .offset(y: -90) 50 | .rotationEffect(.degrees(Double(loadingAnimation))) 51 | .animation(.easeInOut(duration: 1.4).delay(0.6).repeatForever(autoreverses: false)) 52 | 53 | }//End of ZStack 54 | .onAppear(){ 55 | loadingAnimation = 360 56 | } 57 | } 58 | } 59 | 60 | struct CircleColors_Previews: PreviewProvider { 61 | static var previews: some View { 62 | CircleColors() 63 | .preferredColorScheme(.dark) 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /SwiftUI-Loading-Animation/CircleFlip.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CircleFlip.swift 3 | // SwiftUI-Loading-Animation 4 | // 5 | // Created by Adam on 5/24/21. 6 | // 7 | 8 | import SwiftUI 9 | 10 | struct CircleFlip: View { 11 | 12 | @State private var flipAnimation = 25 13 | 14 | var body: some View { 15 | ZStack{ 16 | 17 | Circle() 18 | .foregroundColor(Color(#colorLiteral(red: 1, green: 0.0862745098, blue: 0.3647058824, alpha: 1))) 19 | .frame(width: 50, height: 50, alignment: .center) 20 | .offset(x: CGFloat(-flipAnimation)) 21 | .animation(.linear(duration: 0.5)) 22 | .zIndex(flipAnimation == 25 ? 1 : 0) 23 | 24 | Circle() 25 | .foregroundColor(Color(#colorLiteral(red: 0, green: 0.3803921569, blue: 0.6588235294, alpha: 1))) 26 | .frame(width: 50, height: 50, alignment: .center) 27 | .offset(x: CGFloat(flipAnimation)) 28 | .animation(.linear(duration: 0.5)) 29 | .zIndex(flipAnimation == 25 ? 0 : 1) 30 | 31 | }//End of ZStack 32 | .onAppear(){ 33 | Timer.scheduledTimer(withTimeInterval: 0.5, repeats: true) { _ in 34 | flipAnimation = flipAnimation == 25 ? -25 : 25 35 | } 36 | //MARK: - To fire Timer immediately 37 | // .fire() 38 | } 39 | } 40 | } 41 | 42 | struct CircleFlip_Previews: PreviewProvider { 43 | static var previews: some View { 44 | CircleFlip() 45 | .preferredColorScheme(/*@START_MENU_TOKEN@*/.dark/*@END_MENU_TOKEN@*/) 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /SwiftUI-Loading-Animation/CircleGradual.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CircleGradual.swift 3 | // SwiftUI-Loading-Animation 4 | // 5 | // Created by Adam on 5/23/21. 6 | // 7 | 8 | import SwiftUI 9 | 10 | struct CircleGradual: View { 11 | 12 | @State private var gradualOpacityAnimation = 1.0 13 | @State private var gradualScaleAnimation: CGFloat = 1.0 14 | 15 | var body: some View { 16 | 17 | ZStack{ 18 | 19 | Circle() 20 | .frame(width: 30, height: 30, alignment: .center) 21 | .foregroundColor(Color(#colorLiteral(red: 1, green: 0.9607843137, blue: 0.6705882353, alpha: 1))) 22 | .opacity(gradualOpacityAnimation) 23 | .scaleEffect(gradualScaleAnimation) 24 | .offset(y: gradualOpacityAnimation == 0.5 ? 0 : -55) 25 | .animation(.easeOut(duration: 0.25)) 26 | 27 | Circle() 28 | .frame(width: 30, height: 30, alignment: .center) 29 | .foregroundColor(Color(#colorLiteral(red: 1, green: 0.9607843137, blue: 0.6705882353, alpha: 1))) 30 | .opacity(gradualOpacityAnimation) 31 | .scaleEffect(gradualScaleAnimation) 32 | .offset(x: gradualOpacityAnimation == 0.5 ? 0 : 55) 33 | .rotationEffect(.degrees(-45)) 34 | .animation(.easeOut(duration: 0.25).delay(0.25)) 35 | 36 | Circle() 37 | .frame(width: 30, height: 30, alignment: .center) 38 | .foregroundColor(Color(#colorLiteral(red: 1, green: 0.9607843137, blue: 0.6705882353, alpha: 1))) 39 | .opacity(gradualOpacityAnimation) 40 | .scaleEffect(gradualScaleAnimation) 41 | .offset(x: gradualOpacityAnimation == 0.5 ? 0 : 55) 42 | .animation(.easeOut(duration: 0.25).delay(0.5)) 43 | 44 | Circle() 45 | .frame(width: 30, height: 30, alignment: .center) 46 | .foregroundColor(Color(#colorLiteral(red: 1, green: 0.9607843137, blue: 0.6705882353, alpha: 1))) 47 | .opacity(gradualOpacityAnimation) 48 | .scaleEffect(gradualScaleAnimation) 49 | .offset(x: gradualOpacityAnimation == 0.5 ? 0 : 55) 50 | .rotationEffect(.degrees(45)) 51 | .animation(.easeOut(duration: 0.25).delay(0.75)) 52 | 53 | Circle() 54 | .frame(width: 30, height: 30, alignment: .center) 55 | .foregroundColor(Color(#colorLiteral(red: 1, green: 0.9607843137, blue: 0.6705882353, alpha: 1))) 56 | .opacity(gradualOpacityAnimation) 57 | .scaleEffect(gradualScaleAnimation) 58 | .offset(y: gradualOpacityAnimation == 0.5 ? 0 : 55) 59 | .animation(.linear(duration: 0.25).delay(1)) 60 | 61 | Circle() 62 | .frame(width: 30, height: 30, alignment: .center) 63 | .foregroundColor(Color(#colorLiteral(red: 1, green: 0.9607843137, blue: 0.6705882353, alpha: 1))) 64 | .opacity(gradualOpacityAnimation) 65 | .scaleEffect(gradualScaleAnimation) 66 | .offset(y: gradualOpacityAnimation == 0.5 ? 0 : 55) 67 | .rotationEffect(.degrees(45)) 68 | .animation(.easeOut(duration: 0.25).delay(1.25)) 69 | 70 | Circle() 71 | .frame(width: 30, height: 30, alignment: .center) 72 | .foregroundColor(Color(#colorLiteral(red: 1, green: 0.9607843137, blue: 0.6705882353, alpha: 1))) 73 | .opacity(gradualOpacityAnimation) 74 | .scaleEffect(gradualScaleAnimation) 75 | .offset(x: gradualOpacityAnimation == 0.5 ? 0 : -55) 76 | .animation(.easeOut(duration: 0.25).delay(1.5)) 77 | 78 | Circle() 79 | .frame(width: 30, height: 30, alignment: .center) 80 | .foregroundColor(Color(#colorLiteral(red: 1, green: 0.9607843137, blue: 0.6705882353, alpha: 1))) 81 | .opacity(gradualOpacityAnimation) 82 | .scaleEffect(gradualScaleAnimation) 83 | .offset(y: gradualOpacityAnimation == 0.5 ? 0 : -55) 84 | .rotationEffect(.degrees(-45)) 85 | .animation(.easeOut(duration: 0.25).delay(1.75)) 86 | 87 | Circle() 88 | .frame(width: 30, height: 30, alignment: .center) 89 | .foregroundColor(Color(#colorLiteral(red: 1, green: 0.9607843137, blue: 0.6705882353, alpha: 1))) 90 | 91 | }//End of ZStack 92 | .onAppear(){ 93 | Timer.scheduledTimer(withTimeInterval: 2, repeats: true) { _ in 94 | 95 | gradualOpacityAnimation = gradualOpacityAnimation == 1.0 ? 0.5 : 1 96 | 97 | gradualScaleAnimation = gradualScaleAnimation == 1.0 ? 0.5 : 1.0 98 | } 99 | //MARK: - To fire Timer immediately 100 | // .fire() 101 | } 102 | } 103 | } 104 | 105 | struct CircleGradual_Previews: PreviewProvider { 106 | static var previews: some View { 107 | CircleGradual() 108 | .preferredColorScheme(/*@START_MENU_TOKEN@*/.dark/*@END_MENU_TOKEN@*/) 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /SwiftUI-Loading-Animation/CircleOpacity.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CircleOpacity.swift 3 | // SwiftUI-Loading-Animation 4 | // 5 | // Created by Adam on 5/20/21. 6 | // 7 | 8 | import SwiftUI 9 | 10 | struct CircleOpacity: View { 11 | 12 | @State private var loadingAnimation = 0 13 | 14 | var body: some View { 15 | 16 | ZStack{ 17 | 18 | //MARK: - First Animation 19 | ZStack{ 20 | 21 | Circle() 22 | .frame(width: 10, height: 10, alignment: .center) 23 | .foregroundColor(Color(#colorLiteral(red: 1, green: 0.9607843137, blue: 0.6705882353, alpha: 1)).opacity(0.15)) 24 | .offset(x: loadingAnimation == 360 ? 55 : 0) 25 | .rotationEffect(.degrees(-45)) 26 | 27 | Circle() 28 | .frame(width: 13, height: 13, alignment: .center) 29 | .foregroundColor(Color(#colorLiteral(red: 1, green: 0.9607843137, blue: 0.6705882353, alpha: 1)).opacity(0.2)) 30 | .offset(x: loadingAnimation == 360 ? 55 : 0) 31 | 32 | Circle() 33 | .frame(width: 16, height: 16, alignment: .center) 34 | .foregroundColor(Color(#colorLiteral(red: 1, green: 0.9607843137, blue: 0.6705882353, alpha: 1)).opacity(0.3)) 35 | .offset(x: loadingAnimation == 360 ? 55 : 0) 36 | .rotationEffect(.degrees(45)) 37 | 38 | Circle() 39 | .frame(width: 19, height: 19, alignment: .center) 40 | .foregroundColor(Color(#colorLiteral(red: 1, green: 0.9607843137, blue: 0.6705882353, alpha: 1)).opacity(0.4)) 41 | .offset(y: loadingAnimation == 360 ? 55 : 0) 42 | 43 | Circle() 44 | .frame(width: 21, height: 21, alignment: .center) 45 | .foregroundColor(Color(#colorLiteral(red: 1, green: 0.9607843137, blue: 0.6705882353, alpha: 1)).opacity(0.5)) 46 | .offset(x: loadingAnimation == 360 ? -55 : 0) 47 | .rotationEffect(.degrees(-45)) 48 | 49 | Circle() 50 | .frame(width: 24, height: 24, alignment: .center) 51 | .foregroundColor(Color(#colorLiteral(red: 1, green: 0.9607843137, blue: 0.6705882353, alpha: 1)).opacity(0.6)) 52 | .offset(x: loadingAnimation == 360 ? -55 : 0) 53 | 54 | Circle() 55 | .frame(width: 27, height: 27, alignment: .center) 56 | .foregroundColor(Color(#colorLiteral(red: 1, green: 0.9607843137, blue: 0.6705882353, alpha: 1)).opacity(0.8)) 57 | .offset(x: loadingAnimation == 360 ? -55 : 0) 58 | .rotationEffect(.degrees(45)) 59 | 60 | Circle() 61 | .frame(width: 30, height: 30, alignment: .center) 62 | .foregroundColor(Color(#colorLiteral(red: 1, green: 0.9607843137, blue: 0.6705882353, alpha: 1))) 63 | .offset(y: loadingAnimation == 360 ? -55 : 0) 64 | 65 | }//End of ZStack 66 | .opacity( loadingAnimation == 360 ? 0 : 1) 67 | .animation(.linear(duration: 1.8).repeatCount(1).delay(1.6)) 68 | 69 | //MARK: - Second Animation 70 | ZStack{ 71 | 72 | Circle() 73 | .frame(width: 10, height: 10, alignment: .center) 74 | .foregroundColor(Color(#colorLiteral(red: 1, green: 0.9607843137, blue: 0.6705882353, alpha: 1)).opacity(0.15)) 75 | .offset(x: 55) 76 | .rotationEffect(.degrees(-45)) 77 | 78 | Circle() 79 | .frame(width: 13, height: 13, alignment: .center) 80 | .foregroundColor(Color(#colorLiteral(red: 1, green: 0.9607843137, blue: 0.6705882353, alpha: 1)).opacity(0.2)) 81 | .offset(x: 55) 82 | 83 | Circle() 84 | .frame(width: 16, height: 16, alignment: .center) 85 | .foregroundColor(Color(#colorLiteral(red: 1, green: 0.9607843137, blue: 0.6705882353, alpha: 1)).opacity(0.3)) 86 | .offset(x: 55) 87 | .rotationEffect(.degrees(45)) 88 | 89 | Circle() 90 | .frame(width: 19, height: 19, alignment: .center) 91 | .foregroundColor(Color(#colorLiteral(red: 1, green: 0.9607843137, blue: 0.6705882353, alpha: 1)).opacity(0.4)) 92 | .offset(y: 55) 93 | 94 | Circle() 95 | .frame(width: 21, height: 21, alignment: .center) 96 | .foregroundColor(Color(#colorLiteral(red: 1, green: 0.9607843137, blue: 0.6705882353, alpha: 1)).opacity(0.5)) 97 | .offset(x: -55) 98 | .rotationEffect(.degrees(-45)) 99 | 100 | Circle() 101 | .frame(width: 24, height: 24, alignment: .center) 102 | .foregroundColor(Color(#colorLiteral(red: 1, green: 0.9607843137, blue: 0.6705882353, alpha: 1)).opacity(0.6)) 103 | .offset(x: -55) 104 | 105 | Circle() 106 | .frame(width: 27, height: 27, alignment: .center) 107 | .foregroundColor(Color(#colorLiteral(red: 1, green: 0.9607843137, blue: 0.6705882353, alpha: 1)).opacity(0.8)) 108 | .offset(x: -55) 109 | .rotationEffect(.degrees(45)) 110 | 111 | Circle() 112 | .frame(width: 30, height: 30, alignment: .center) 113 | .foregroundColor(Color(#colorLiteral(red: 1, green: 0.9607843137, blue: 0.6705882353, alpha: 1))) 114 | .offset(y: -55) 115 | 116 | }//End of ZStack 117 | .rotationEffect(.degrees(Double(loadingAnimation))) 118 | .animation(.linear(duration: 1.8).repeatForever(autoreverses: false).delay(3)) 119 | 120 | }//End of ZStack 121 | .onAppear(){ 122 | loadingAnimation = 360 123 | } 124 | } 125 | } 126 | 127 | struct CircleOpacity_Previews: PreviewProvider { 128 | static var previews: some View { 129 | CircleOpacity() 130 | .preferredColorScheme(.dark) 131 | } 132 | } 133 | -------------------------------------------------------------------------------- /SwiftUI-Loading-Animation/CubeOffset.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CubeOffset.swift 3 | // SwiftUI-Loading-Animation 4 | // 5 | // Created by Adam on 5/22/21. 6 | // 7 | 8 | import SwiftUI 9 | 10 | struct CubeOffset: View { 11 | 12 | @State private var yellowSquareAnimationX = CGFloat(-25) 13 | @State private var yellowSquareAnimationY = CGFloat(25) 14 | 15 | @State private var purpleSquareAnimationX = CGFloat(25) 16 | @State private var purpleSquareAnimationY = CGFloat(-25) 17 | 18 | @State private var greenSquareAnimationX = CGFloat(25) 19 | @State private var greenSquareAnimationY = CGFloat(25) 20 | 21 | @State private var orangeSquareAnimationX = CGFloat(-25) 22 | @State private var orangeSquareAnimationY = CGFloat(-25) 23 | 24 | var body: some View { 25 | 26 | ZStack{ 27 | 28 | Color(#colorLiteral(red: 1, green: 0.7960784314, blue: 0.4666666667, alpha: 1)) 29 | .frame(width: 40, height: 40, alignment: .center) 30 | .offset(x: yellowSquareAnimationX, y: yellowSquareAnimationY) 31 | .animation(.timingCurve(0.33, 1, 0.68, 1, duration: 0.5)) 32 | 33 | Color(#colorLiteral(red: 0.5254901961, green: 0.4784313725, blue: 0.9137254902, alpha: 1)) 34 | .frame(width: 40, height: 40, alignment: .center) 35 | .offset(x: purpleSquareAnimationX, y: purpleSquareAnimationY) 36 | .animation(.timingCurve(0.33, 1, 0.68, 1, duration: 0.5)) 37 | 38 | Color(#colorLiteral(red: 0, green: 0.7215686275, blue: 0.662745098, alpha: 1)) 39 | .frame(width: 40, height: 40, alignment: .center) 40 | .offset(x: greenSquareAnimationX, y: greenSquareAnimationY) 41 | .animation(.timingCurve(0.33, 1, 0.68, 1, duration: 0.5)) 42 | 43 | Color(#colorLiteral(red: 0.9960784314, green: 0.4274509804, blue: 0.4509803922, alpha: 1)) 44 | .frame(width: 40, height: 40, alignment: .center) 45 | .offset(x: orangeSquareAnimationX, y: orangeSquareAnimationY) 46 | .animation(.timingCurve(0.33, 1, 0.68, 1, duration: 0.5)) 47 | 48 | }//End of ZStack 49 | .onAppear(){ 50 | 51 | Timer.scheduledTimer(withTimeInterval: 2, repeats: true) { _ in 52 | yellowSquareAnimationX = -20 53 | yellowSquareAnimationY = 20 54 | purpleSquareAnimationX = 20 55 | purpleSquareAnimationY = -20 56 | greenSquareAnimationX = 20 57 | greenSquareAnimationY = 20 58 | orangeSquareAnimationX = -20 59 | orangeSquareAnimationY = -20 60 | 61 | DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { 62 | orangeSquareAnimationY = 20 63 | greenSquareAnimationY = -20 64 | yellowSquareAnimationX = 20 65 | purpleSquareAnimationX = -20 66 | } 67 | 68 | DispatchQueue.main.asyncAfter(deadline: .now() + 1) { 69 | orangeSquareAnimationX = 20 70 | greenSquareAnimationX = -20 71 | yellowSquareAnimationY = -20 72 | purpleSquareAnimationY = 20 73 | } 74 | 75 | DispatchQueue.main.asyncAfter(deadline: .now() + 1.5) { 76 | orangeSquareAnimationY = -20 77 | greenSquareAnimationY = 20 78 | yellowSquareAnimationX = -20 79 | purpleSquareAnimationX = 20 80 | } 81 | 82 | DispatchQueue.main.asyncAfter(deadline: .now() + 2) { 83 | orangeSquareAnimationX = -20 84 | greenSquareAnimationX = 20 85 | yellowSquareAnimationY = 20 86 | purpleSquareAnimationY = -20 87 | } 88 | } 89 | //MARK: - To fire Timer immediately 90 | // .fire() 91 | } 92 | } 93 | } 94 | 95 | struct CubeOffset_Previews: PreviewProvider { 96 | static var previews: some View { 97 | CubeOffset() 98 | .preferredColorScheme(/*@START_MENU_TOKEN@*/.dark/*@END_MENU_TOKEN@*/) 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /SwiftUI-Loading-Animation/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UIApplicationSceneManifest 24 | 25 | UIApplicationSupportsMultipleScenes 26 | 27 | 28 | UIApplicationSupportsIndirectInputEvents 29 | 30 | UILaunchScreen 31 | 32 | UIRequiredDeviceCapabilities 33 | 34 | armv7 35 | 36 | UISupportedInterfaceOrientations 37 | 38 | UIInterfaceOrientationPortrait 39 | UIInterfaceOrientationLandscapeLeft 40 | UIInterfaceOrientationLandscapeRight 41 | 42 | UISupportedInterfaceOrientations~ipad 43 | 44 | UIInterfaceOrientationPortrait 45 | UIInterfaceOrientationPortraitUpsideDown 46 | UIInterfaceOrientationLandscapeLeft 47 | UIInterfaceOrientationLandscapeRight 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /SwiftUI-Loading-Animation/Preview Content/Preview Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /SwiftUI-Loading-Animation/SwiftUI_Loading_AnimationApp.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SwiftUI_Loading_AnimationApp.swift 3 | // SwiftUI-Loading-Animation 4 | // 5 | // Created by Adam on 5/16/21. 6 | // 7 | 8 | import SwiftUI 9 | 10 | @main 11 | struct SwiftUI_Loading_AnimationApp: App { 12 | var body: some Scene { 13 | WindowGroup { 14 | // CapsuleSpacing() 15 | // CircleColors() 16 | // CircleOpacity() 17 | // CubeOffset() 18 | // CircleFlip() 19 | CircleGradual() 20 | } 21 | } 22 | } 23 | --------------------------------------------------------------------------------