├── .gitignore ├── AnimatedWaveViewExample.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcuserdata │ └── jwi175.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist ├── AnimatedWaveViewExample ├── AnimatedWaveView.swift ├── AppDelegate.swift ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Info.plist ├── PathBuilder.swift ├── RadialGradientLayer.swift └── ViewController.swift ├── AnimatedWaveViewExampleTests ├── AnimatedWaveViewExampleTests.swift └── Info.plist ├── AnimatedWaveViewExampleUITests ├── AnimatedWaveViewExampleUITests.swift └── Info.plist ├── LICENSE ├── README.md └── animatedwaves.gif /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata/ 19 | 20 | ## Other 21 | *.moved-aside 22 | *.xccheckout 23 | *.xcscmblueprint 24 | 25 | ## Obj-C/Swift specific 26 | *.hmap 27 | *.ipa 28 | *.dSYM.zip 29 | *.dSYM 30 | 31 | ## Playgrounds 32 | timeline.xctimeline 33 | playground.xcworkspace 34 | 35 | # Swift Package Manager 36 | # 37 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 38 | # Packages/ 39 | # Package.pins 40 | .build/ 41 | 42 | # CocoaPods 43 | # 44 | # We recommend against adding the Pods directory to your .gitignore. However 45 | # you should judge for yourself, the pros and cons are mentioned at: 46 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 47 | # 48 | # Pods/ 49 | 50 | # Carthage 51 | # 52 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 53 | # Carthage/Checkouts 54 | 55 | Carthage/Build 56 | 57 | # fastlane 58 | # 59 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 60 | # screenshots whenever they are needed. 61 | # For more information about the recommended setup visit: 62 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 63 | 64 | fastlane/report.xml 65 | fastlane/Preview.html 66 | fastlane/screenshots 67 | fastlane/test_output 68 | -------------------------------------------------------------------------------- /AnimatedWaveViewExample.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 48; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 935F84462049E3BF00814A09 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 935F84452049E3BF00814A09 /* AppDelegate.swift */; }; 11 | 935F84482049E3BF00814A09 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 935F84472049E3BF00814A09 /* ViewController.swift */; }; 12 | 935F844B2049E3BF00814A09 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 935F84492049E3BF00814A09 /* Main.storyboard */; }; 13 | 935F844D2049E3BF00814A09 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 935F844C2049E3BF00814A09 /* Assets.xcassets */; }; 14 | 935F84502049E3BF00814A09 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 935F844E2049E3BF00814A09 /* LaunchScreen.storyboard */; }; 15 | 935F845B2049E3BF00814A09 /* AnimatedWaveViewExampleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 935F845A2049E3BF00814A09 /* AnimatedWaveViewExampleTests.swift */; }; 16 | 935F84662049E3BF00814A09 /* AnimatedWaveViewExampleUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 935F84652049E3BF00814A09 /* AnimatedWaveViewExampleUITests.swift */; }; 17 | 935F84742049E3E000814A09 /* AnimatedWaveView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 935F84732049E3E000814A09 /* AnimatedWaveView.swift */; }; 18 | 935F84762049E44D00814A09 /* RadialGradientLayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 935F84752049E44D00814A09 /* RadialGradientLayer.swift */; }; 19 | 935F84782049E6EB00814A09 /* PathBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 935F84772049E6EB00814A09 /* PathBuilder.swift */; }; 20 | /* End PBXBuildFile section */ 21 | 22 | /* Begin PBXContainerItemProxy section */ 23 | 935F84572049E3BF00814A09 /* PBXContainerItemProxy */ = { 24 | isa = PBXContainerItemProxy; 25 | containerPortal = 935F843A2049E3BF00814A09 /* Project object */; 26 | proxyType = 1; 27 | remoteGlobalIDString = 935F84412049E3BF00814A09; 28 | remoteInfo = AnimatedWaveViewExample; 29 | }; 30 | 935F84622049E3BF00814A09 /* PBXContainerItemProxy */ = { 31 | isa = PBXContainerItemProxy; 32 | containerPortal = 935F843A2049E3BF00814A09 /* Project object */; 33 | proxyType = 1; 34 | remoteGlobalIDString = 935F84412049E3BF00814A09; 35 | remoteInfo = AnimatedWaveViewExample; 36 | }; 37 | /* End PBXContainerItemProxy section */ 38 | 39 | /* Begin PBXFileReference section */ 40 | 935F84422049E3BF00814A09 /* AnimatedWaveViewExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = AnimatedWaveViewExample.app; sourceTree = BUILT_PRODUCTS_DIR; }; 41 | 935F84452049E3BF00814A09 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 42 | 935F84472049E3BF00814A09 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 43 | 935F844A2049E3BF00814A09 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 44 | 935F844C2049E3BF00814A09 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 45 | 935F844F2049E3BF00814A09 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 46 | 935F84512049E3BF00814A09 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 47 | 935F84562049E3BF00814A09 /* AnimatedWaveViewExampleTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = AnimatedWaveViewExampleTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 48 | 935F845A2049E3BF00814A09 /* AnimatedWaveViewExampleTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnimatedWaveViewExampleTests.swift; sourceTree = ""; }; 49 | 935F845C2049E3BF00814A09 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 50 | 935F84612049E3BF00814A09 /* AnimatedWaveViewExampleUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = AnimatedWaveViewExampleUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 51 | 935F84652049E3BF00814A09 /* AnimatedWaveViewExampleUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnimatedWaveViewExampleUITests.swift; sourceTree = ""; }; 52 | 935F84672049E3BF00814A09 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 53 | 935F84732049E3E000814A09 /* AnimatedWaveView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnimatedWaveView.swift; sourceTree = ""; }; 54 | 935F84752049E44D00814A09 /* RadialGradientLayer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadialGradientLayer.swift; sourceTree = ""; }; 55 | 935F84772049E6EB00814A09 /* PathBuilder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PathBuilder.swift; sourceTree = ""; }; 56 | /* End PBXFileReference section */ 57 | 58 | /* Begin PBXFrameworksBuildPhase section */ 59 | 935F843F2049E3BF00814A09 /* Frameworks */ = { 60 | isa = PBXFrameworksBuildPhase; 61 | buildActionMask = 2147483647; 62 | files = ( 63 | ); 64 | runOnlyForDeploymentPostprocessing = 0; 65 | }; 66 | 935F84532049E3BF00814A09 /* Frameworks */ = { 67 | isa = PBXFrameworksBuildPhase; 68 | buildActionMask = 2147483647; 69 | files = ( 70 | ); 71 | runOnlyForDeploymentPostprocessing = 0; 72 | }; 73 | 935F845E2049E3BF00814A09 /* Frameworks */ = { 74 | isa = PBXFrameworksBuildPhase; 75 | buildActionMask = 2147483647; 76 | files = ( 77 | ); 78 | runOnlyForDeploymentPostprocessing = 0; 79 | }; 80 | /* End PBXFrameworksBuildPhase section */ 81 | 82 | /* Begin PBXGroup section */ 83 | 935F84392049E3BF00814A09 = { 84 | isa = PBXGroup; 85 | children = ( 86 | 935F84442049E3BF00814A09 /* AnimatedWaveViewExample */, 87 | 935F84592049E3BF00814A09 /* AnimatedWaveViewExampleTests */, 88 | 935F84642049E3BF00814A09 /* AnimatedWaveViewExampleUITests */, 89 | 935F84432049E3BF00814A09 /* Products */, 90 | ); 91 | sourceTree = ""; 92 | }; 93 | 935F84432049E3BF00814A09 /* Products */ = { 94 | isa = PBXGroup; 95 | children = ( 96 | 935F84422049E3BF00814A09 /* AnimatedWaveViewExample.app */, 97 | 935F84562049E3BF00814A09 /* AnimatedWaveViewExampleTests.xctest */, 98 | 935F84612049E3BF00814A09 /* AnimatedWaveViewExampleUITests.xctest */, 99 | ); 100 | name = Products; 101 | sourceTree = ""; 102 | }; 103 | 935F84442049E3BF00814A09 /* AnimatedWaveViewExample */ = { 104 | isa = PBXGroup; 105 | children = ( 106 | 935F84452049E3BF00814A09 /* AppDelegate.swift */, 107 | 935F84472049E3BF00814A09 /* ViewController.swift */, 108 | 935F84732049E3E000814A09 /* AnimatedWaveView.swift */, 109 | 935F84772049E6EB00814A09 /* PathBuilder.swift */, 110 | 935F84752049E44D00814A09 /* RadialGradientLayer.swift */, 111 | 935F84492049E3BF00814A09 /* Main.storyboard */, 112 | 935F844C2049E3BF00814A09 /* Assets.xcassets */, 113 | 935F844E2049E3BF00814A09 /* LaunchScreen.storyboard */, 114 | 935F84512049E3BF00814A09 /* Info.plist */, 115 | ); 116 | path = AnimatedWaveViewExample; 117 | sourceTree = ""; 118 | }; 119 | 935F84592049E3BF00814A09 /* AnimatedWaveViewExampleTests */ = { 120 | isa = PBXGroup; 121 | children = ( 122 | 935F845A2049E3BF00814A09 /* AnimatedWaveViewExampleTests.swift */, 123 | 935F845C2049E3BF00814A09 /* Info.plist */, 124 | ); 125 | path = AnimatedWaveViewExampleTests; 126 | sourceTree = ""; 127 | }; 128 | 935F84642049E3BF00814A09 /* AnimatedWaveViewExampleUITests */ = { 129 | isa = PBXGroup; 130 | children = ( 131 | 935F84652049E3BF00814A09 /* AnimatedWaveViewExampleUITests.swift */, 132 | 935F84672049E3BF00814A09 /* Info.plist */, 133 | ); 134 | path = AnimatedWaveViewExampleUITests; 135 | sourceTree = ""; 136 | }; 137 | /* End PBXGroup section */ 138 | 139 | /* Begin PBXNativeTarget section */ 140 | 935F84412049E3BF00814A09 /* AnimatedWaveViewExample */ = { 141 | isa = PBXNativeTarget; 142 | buildConfigurationList = 935F846A2049E3BF00814A09 /* Build configuration list for PBXNativeTarget "AnimatedWaveViewExample" */; 143 | buildPhases = ( 144 | 935F843E2049E3BF00814A09 /* Sources */, 145 | 935F843F2049E3BF00814A09 /* Frameworks */, 146 | 935F84402049E3BF00814A09 /* Resources */, 147 | ); 148 | buildRules = ( 149 | ); 150 | dependencies = ( 151 | ); 152 | name = AnimatedWaveViewExample; 153 | productName = AnimatedWaveViewExample; 154 | productReference = 935F84422049E3BF00814A09 /* AnimatedWaveViewExample.app */; 155 | productType = "com.apple.product-type.application"; 156 | }; 157 | 935F84552049E3BF00814A09 /* AnimatedWaveViewExampleTests */ = { 158 | isa = PBXNativeTarget; 159 | buildConfigurationList = 935F846D2049E3BF00814A09 /* Build configuration list for PBXNativeTarget "AnimatedWaveViewExampleTests" */; 160 | buildPhases = ( 161 | 935F84522049E3BF00814A09 /* Sources */, 162 | 935F84532049E3BF00814A09 /* Frameworks */, 163 | 935F84542049E3BF00814A09 /* Resources */, 164 | ); 165 | buildRules = ( 166 | ); 167 | dependencies = ( 168 | 935F84582049E3BF00814A09 /* PBXTargetDependency */, 169 | ); 170 | name = AnimatedWaveViewExampleTests; 171 | productName = AnimatedWaveViewExampleTests; 172 | productReference = 935F84562049E3BF00814A09 /* AnimatedWaveViewExampleTests.xctest */; 173 | productType = "com.apple.product-type.bundle.unit-test"; 174 | }; 175 | 935F84602049E3BF00814A09 /* AnimatedWaveViewExampleUITests */ = { 176 | isa = PBXNativeTarget; 177 | buildConfigurationList = 935F84702049E3BF00814A09 /* Build configuration list for PBXNativeTarget "AnimatedWaveViewExampleUITests" */; 178 | buildPhases = ( 179 | 935F845D2049E3BF00814A09 /* Sources */, 180 | 935F845E2049E3BF00814A09 /* Frameworks */, 181 | 935F845F2049E3BF00814A09 /* Resources */, 182 | ); 183 | buildRules = ( 184 | ); 185 | dependencies = ( 186 | 935F84632049E3BF00814A09 /* PBXTargetDependency */, 187 | ); 188 | name = AnimatedWaveViewExampleUITests; 189 | productName = AnimatedWaveViewExampleUITests; 190 | productReference = 935F84612049E3BF00814A09 /* AnimatedWaveViewExampleUITests.xctest */; 191 | productType = "com.apple.product-type.bundle.ui-testing"; 192 | }; 193 | /* End PBXNativeTarget section */ 194 | 195 | /* Begin PBXProject section */ 196 | 935F843A2049E3BF00814A09 /* Project object */ = { 197 | isa = PBXProject; 198 | attributes = { 199 | LastSwiftUpdateCheck = 0920; 200 | LastUpgradeCheck = 0920; 201 | ORGANIZATIONNAME = Nike; 202 | TargetAttributes = { 203 | 935F84412049E3BF00814A09 = { 204 | CreatedOnToolsVersion = 9.2; 205 | ProvisioningStyle = Automatic; 206 | }; 207 | 935F84552049E3BF00814A09 = { 208 | CreatedOnToolsVersion = 9.2; 209 | ProvisioningStyle = Automatic; 210 | TestTargetID = 935F84412049E3BF00814A09; 211 | }; 212 | 935F84602049E3BF00814A09 = { 213 | CreatedOnToolsVersion = 9.2; 214 | ProvisioningStyle = Automatic; 215 | TestTargetID = 935F84412049E3BF00814A09; 216 | }; 217 | }; 218 | }; 219 | buildConfigurationList = 935F843D2049E3BF00814A09 /* Build configuration list for PBXProject "AnimatedWaveViewExample" */; 220 | compatibilityVersion = "Xcode 8.0"; 221 | developmentRegion = en; 222 | hasScannedForEncodings = 0; 223 | knownRegions = ( 224 | en, 225 | Base, 226 | ); 227 | mainGroup = 935F84392049E3BF00814A09; 228 | productRefGroup = 935F84432049E3BF00814A09 /* Products */; 229 | projectDirPath = ""; 230 | projectRoot = ""; 231 | targets = ( 232 | 935F84412049E3BF00814A09 /* AnimatedWaveViewExample */, 233 | 935F84552049E3BF00814A09 /* AnimatedWaveViewExampleTests */, 234 | 935F84602049E3BF00814A09 /* AnimatedWaveViewExampleUITests */, 235 | ); 236 | }; 237 | /* End PBXProject section */ 238 | 239 | /* Begin PBXResourcesBuildPhase section */ 240 | 935F84402049E3BF00814A09 /* Resources */ = { 241 | isa = PBXResourcesBuildPhase; 242 | buildActionMask = 2147483647; 243 | files = ( 244 | 935F84502049E3BF00814A09 /* LaunchScreen.storyboard in Resources */, 245 | 935F844D2049E3BF00814A09 /* Assets.xcassets in Resources */, 246 | 935F844B2049E3BF00814A09 /* Main.storyboard in Resources */, 247 | ); 248 | runOnlyForDeploymentPostprocessing = 0; 249 | }; 250 | 935F84542049E3BF00814A09 /* Resources */ = { 251 | isa = PBXResourcesBuildPhase; 252 | buildActionMask = 2147483647; 253 | files = ( 254 | ); 255 | runOnlyForDeploymentPostprocessing = 0; 256 | }; 257 | 935F845F2049E3BF00814A09 /* Resources */ = { 258 | isa = PBXResourcesBuildPhase; 259 | buildActionMask = 2147483647; 260 | files = ( 261 | ); 262 | runOnlyForDeploymentPostprocessing = 0; 263 | }; 264 | /* End PBXResourcesBuildPhase section */ 265 | 266 | /* Begin PBXSourcesBuildPhase section */ 267 | 935F843E2049E3BF00814A09 /* Sources */ = { 268 | isa = PBXSourcesBuildPhase; 269 | buildActionMask = 2147483647; 270 | files = ( 271 | 935F84762049E44D00814A09 /* RadialGradientLayer.swift in Sources */, 272 | 935F84482049E3BF00814A09 /* ViewController.swift in Sources */, 273 | 935F84742049E3E000814A09 /* AnimatedWaveView.swift in Sources */, 274 | 935F84462049E3BF00814A09 /* AppDelegate.swift in Sources */, 275 | 935F84782049E6EB00814A09 /* PathBuilder.swift in Sources */, 276 | ); 277 | runOnlyForDeploymentPostprocessing = 0; 278 | }; 279 | 935F84522049E3BF00814A09 /* Sources */ = { 280 | isa = PBXSourcesBuildPhase; 281 | buildActionMask = 2147483647; 282 | files = ( 283 | 935F845B2049E3BF00814A09 /* AnimatedWaveViewExampleTests.swift in Sources */, 284 | ); 285 | runOnlyForDeploymentPostprocessing = 0; 286 | }; 287 | 935F845D2049E3BF00814A09 /* Sources */ = { 288 | isa = PBXSourcesBuildPhase; 289 | buildActionMask = 2147483647; 290 | files = ( 291 | 935F84662049E3BF00814A09 /* AnimatedWaveViewExampleUITests.swift in Sources */, 292 | ); 293 | runOnlyForDeploymentPostprocessing = 0; 294 | }; 295 | /* End PBXSourcesBuildPhase section */ 296 | 297 | /* Begin PBXTargetDependency section */ 298 | 935F84582049E3BF00814A09 /* PBXTargetDependency */ = { 299 | isa = PBXTargetDependency; 300 | target = 935F84412049E3BF00814A09 /* AnimatedWaveViewExample */; 301 | targetProxy = 935F84572049E3BF00814A09 /* PBXContainerItemProxy */; 302 | }; 303 | 935F84632049E3BF00814A09 /* PBXTargetDependency */ = { 304 | isa = PBXTargetDependency; 305 | target = 935F84412049E3BF00814A09 /* AnimatedWaveViewExample */; 306 | targetProxy = 935F84622049E3BF00814A09 /* PBXContainerItemProxy */; 307 | }; 308 | /* End PBXTargetDependency section */ 309 | 310 | /* Begin PBXVariantGroup section */ 311 | 935F84492049E3BF00814A09 /* Main.storyboard */ = { 312 | isa = PBXVariantGroup; 313 | children = ( 314 | 935F844A2049E3BF00814A09 /* Base */, 315 | ); 316 | name = Main.storyboard; 317 | sourceTree = ""; 318 | }; 319 | 935F844E2049E3BF00814A09 /* LaunchScreen.storyboard */ = { 320 | isa = PBXVariantGroup; 321 | children = ( 322 | 935F844F2049E3BF00814A09 /* Base */, 323 | ); 324 | name = LaunchScreen.storyboard; 325 | sourceTree = ""; 326 | }; 327 | /* End PBXVariantGroup section */ 328 | 329 | /* Begin XCBuildConfiguration section */ 330 | 935F84682049E3BF00814A09 /* Debug */ = { 331 | isa = XCBuildConfiguration; 332 | buildSettings = { 333 | ALWAYS_SEARCH_USER_PATHS = NO; 334 | CLANG_ANALYZER_NONNULL = YES; 335 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 336 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 337 | CLANG_CXX_LIBRARY = "libc++"; 338 | CLANG_ENABLE_MODULES = YES; 339 | CLANG_ENABLE_OBJC_ARC = YES; 340 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 341 | CLANG_WARN_BOOL_CONVERSION = YES; 342 | CLANG_WARN_COMMA = YES; 343 | CLANG_WARN_CONSTANT_CONVERSION = YES; 344 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 345 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 346 | CLANG_WARN_EMPTY_BODY = YES; 347 | CLANG_WARN_ENUM_CONVERSION = YES; 348 | CLANG_WARN_INFINITE_RECURSION = YES; 349 | CLANG_WARN_INT_CONVERSION = YES; 350 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 351 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 352 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 353 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 354 | CLANG_WARN_STRICT_PROTOTYPES = YES; 355 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 356 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 357 | CLANG_WARN_UNREACHABLE_CODE = YES; 358 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 359 | CODE_SIGN_IDENTITY = "iPhone Developer"; 360 | COPY_PHASE_STRIP = NO; 361 | DEBUG_INFORMATION_FORMAT = dwarf; 362 | ENABLE_STRICT_OBJC_MSGSEND = YES; 363 | ENABLE_TESTABILITY = YES; 364 | GCC_C_LANGUAGE_STANDARD = gnu11; 365 | GCC_DYNAMIC_NO_PIC = NO; 366 | GCC_NO_COMMON_BLOCKS = YES; 367 | GCC_OPTIMIZATION_LEVEL = 0; 368 | GCC_PREPROCESSOR_DEFINITIONS = ( 369 | "DEBUG=1", 370 | "$(inherited)", 371 | ); 372 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 373 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 374 | GCC_WARN_UNDECLARED_SELECTOR = YES; 375 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 376 | GCC_WARN_UNUSED_FUNCTION = YES; 377 | GCC_WARN_UNUSED_VARIABLE = YES; 378 | IPHONEOS_DEPLOYMENT_TARGET = 11.2; 379 | MTL_ENABLE_DEBUG_INFO = YES; 380 | ONLY_ACTIVE_ARCH = YES; 381 | SDKROOT = iphoneos; 382 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 383 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 384 | }; 385 | name = Debug; 386 | }; 387 | 935F84692049E3BF00814A09 /* Release */ = { 388 | isa = XCBuildConfiguration; 389 | buildSettings = { 390 | ALWAYS_SEARCH_USER_PATHS = NO; 391 | CLANG_ANALYZER_NONNULL = YES; 392 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 393 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 394 | CLANG_CXX_LIBRARY = "libc++"; 395 | CLANG_ENABLE_MODULES = YES; 396 | CLANG_ENABLE_OBJC_ARC = YES; 397 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 398 | CLANG_WARN_BOOL_CONVERSION = YES; 399 | CLANG_WARN_COMMA = YES; 400 | CLANG_WARN_CONSTANT_CONVERSION = YES; 401 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 402 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 403 | CLANG_WARN_EMPTY_BODY = YES; 404 | CLANG_WARN_ENUM_CONVERSION = YES; 405 | CLANG_WARN_INFINITE_RECURSION = YES; 406 | CLANG_WARN_INT_CONVERSION = YES; 407 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 408 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 409 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 410 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 411 | CLANG_WARN_STRICT_PROTOTYPES = YES; 412 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 413 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 414 | CLANG_WARN_UNREACHABLE_CODE = YES; 415 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 416 | CODE_SIGN_IDENTITY = "iPhone Developer"; 417 | COPY_PHASE_STRIP = NO; 418 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 419 | ENABLE_NS_ASSERTIONS = NO; 420 | ENABLE_STRICT_OBJC_MSGSEND = YES; 421 | GCC_C_LANGUAGE_STANDARD = gnu11; 422 | GCC_NO_COMMON_BLOCKS = YES; 423 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 424 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 425 | GCC_WARN_UNDECLARED_SELECTOR = YES; 426 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 427 | GCC_WARN_UNUSED_FUNCTION = YES; 428 | GCC_WARN_UNUSED_VARIABLE = YES; 429 | IPHONEOS_DEPLOYMENT_TARGET = 11.2; 430 | MTL_ENABLE_DEBUG_INFO = NO; 431 | SDKROOT = iphoneos; 432 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 433 | VALIDATE_PRODUCT = YES; 434 | }; 435 | name = Release; 436 | }; 437 | 935F846B2049E3BF00814A09 /* Debug */ = { 438 | isa = XCBuildConfiguration; 439 | buildSettings = { 440 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 441 | CODE_SIGN_STYLE = Automatic; 442 | DEVELOPMENT_TEAM = YB65KBNGN6; 443 | INFOPLIST_FILE = AnimatedWaveViewExample/Info.plist; 444 | IPHONEOS_DEPLOYMENT_TARGET = 10.0; 445 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 446 | PRODUCT_BUNDLE_IDENTIFIER = com.s23NYC.AnimatedWaveViewExample; 447 | PRODUCT_NAME = "$(TARGET_NAME)"; 448 | SWIFT_VERSION = 4.0; 449 | TARGETED_DEVICE_FAMILY = "1,2"; 450 | }; 451 | name = Debug; 452 | }; 453 | 935F846C2049E3BF00814A09 /* Release */ = { 454 | isa = XCBuildConfiguration; 455 | buildSettings = { 456 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 457 | CODE_SIGN_STYLE = Automatic; 458 | DEVELOPMENT_TEAM = YB65KBNGN6; 459 | INFOPLIST_FILE = AnimatedWaveViewExample/Info.plist; 460 | IPHONEOS_DEPLOYMENT_TARGET = 10.0; 461 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 462 | PRODUCT_BUNDLE_IDENTIFIER = com.s23NYC.AnimatedWaveViewExample; 463 | PRODUCT_NAME = "$(TARGET_NAME)"; 464 | SWIFT_VERSION = 4.0; 465 | TARGETED_DEVICE_FAMILY = "1,2"; 466 | }; 467 | name = Release; 468 | }; 469 | 935F846E2049E3BF00814A09 /* Debug */ = { 470 | isa = XCBuildConfiguration; 471 | buildSettings = { 472 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 473 | BUNDLE_LOADER = "$(TEST_HOST)"; 474 | CODE_SIGN_STYLE = Automatic; 475 | DEVELOPMENT_TEAM = YB65KBNGN6; 476 | INFOPLIST_FILE = AnimatedWaveViewExampleTests/Info.plist; 477 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 478 | PRODUCT_BUNDLE_IDENTIFIER = com.s23NYC.AnimatedWaveViewExampleTests; 479 | PRODUCT_NAME = "$(TARGET_NAME)"; 480 | SWIFT_VERSION = 4.0; 481 | TARGETED_DEVICE_FAMILY = "1,2"; 482 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/AnimatedWaveViewExample.app/AnimatedWaveViewExample"; 483 | }; 484 | name = Debug; 485 | }; 486 | 935F846F2049E3BF00814A09 /* Release */ = { 487 | isa = XCBuildConfiguration; 488 | buildSettings = { 489 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 490 | BUNDLE_LOADER = "$(TEST_HOST)"; 491 | CODE_SIGN_STYLE = Automatic; 492 | DEVELOPMENT_TEAM = YB65KBNGN6; 493 | INFOPLIST_FILE = AnimatedWaveViewExampleTests/Info.plist; 494 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 495 | PRODUCT_BUNDLE_IDENTIFIER = com.s23NYC.AnimatedWaveViewExampleTests; 496 | PRODUCT_NAME = "$(TARGET_NAME)"; 497 | SWIFT_VERSION = 4.0; 498 | TARGETED_DEVICE_FAMILY = "1,2"; 499 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/AnimatedWaveViewExample.app/AnimatedWaveViewExample"; 500 | }; 501 | name = Release; 502 | }; 503 | 935F84712049E3BF00814A09 /* Debug */ = { 504 | isa = XCBuildConfiguration; 505 | buildSettings = { 506 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 507 | CODE_SIGN_STYLE = Automatic; 508 | DEVELOPMENT_TEAM = YB65KBNGN6; 509 | INFOPLIST_FILE = AnimatedWaveViewExampleUITests/Info.plist; 510 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 511 | PRODUCT_BUNDLE_IDENTIFIER = com.s23NYC.AnimatedWaveViewExampleUITests; 512 | PRODUCT_NAME = "$(TARGET_NAME)"; 513 | SWIFT_VERSION = 4.0; 514 | TARGETED_DEVICE_FAMILY = "1,2"; 515 | TEST_TARGET_NAME = AnimatedWaveViewExample; 516 | }; 517 | name = Debug; 518 | }; 519 | 935F84722049E3BF00814A09 /* Release */ = { 520 | isa = XCBuildConfiguration; 521 | buildSettings = { 522 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 523 | CODE_SIGN_STYLE = Automatic; 524 | DEVELOPMENT_TEAM = YB65KBNGN6; 525 | INFOPLIST_FILE = AnimatedWaveViewExampleUITests/Info.plist; 526 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 527 | PRODUCT_BUNDLE_IDENTIFIER = com.s23NYC.AnimatedWaveViewExampleUITests; 528 | PRODUCT_NAME = "$(TARGET_NAME)"; 529 | SWIFT_VERSION = 4.0; 530 | TARGETED_DEVICE_FAMILY = "1,2"; 531 | TEST_TARGET_NAME = AnimatedWaveViewExample; 532 | }; 533 | name = Release; 534 | }; 535 | /* End XCBuildConfiguration section */ 536 | 537 | /* Begin XCConfigurationList section */ 538 | 935F843D2049E3BF00814A09 /* Build configuration list for PBXProject "AnimatedWaveViewExample" */ = { 539 | isa = XCConfigurationList; 540 | buildConfigurations = ( 541 | 935F84682049E3BF00814A09 /* Debug */, 542 | 935F84692049E3BF00814A09 /* Release */, 543 | ); 544 | defaultConfigurationIsVisible = 0; 545 | defaultConfigurationName = Release; 546 | }; 547 | 935F846A2049E3BF00814A09 /* Build configuration list for PBXNativeTarget "AnimatedWaveViewExample" */ = { 548 | isa = XCConfigurationList; 549 | buildConfigurations = ( 550 | 935F846B2049E3BF00814A09 /* Debug */, 551 | 935F846C2049E3BF00814A09 /* Release */, 552 | ); 553 | defaultConfigurationIsVisible = 0; 554 | defaultConfigurationName = Release; 555 | }; 556 | 935F846D2049E3BF00814A09 /* Build configuration list for PBXNativeTarget "AnimatedWaveViewExampleTests" */ = { 557 | isa = XCConfigurationList; 558 | buildConfigurations = ( 559 | 935F846E2049E3BF00814A09 /* Debug */, 560 | 935F846F2049E3BF00814A09 /* Release */, 561 | ); 562 | defaultConfigurationIsVisible = 0; 563 | defaultConfigurationName = Release; 564 | }; 565 | 935F84702049E3BF00814A09 /* Build configuration list for PBXNativeTarget "AnimatedWaveViewExampleUITests" */ = { 566 | isa = XCConfigurationList; 567 | buildConfigurations = ( 568 | 935F84712049E3BF00814A09 /* Debug */, 569 | 935F84722049E3BF00814A09 /* Release */, 570 | ); 571 | defaultConfigurationIsVisible = 0; 572 | defaultConfigurationName = Release; 573 | }; 574 | /* End XCConfigurationList section */ 575 | }; 576 | rootObject = 935F843A2049E3BF00814A09 /* Project object */; 577 | } 578 | -------------------------------------------------------------------------------- /AnimatedWaveViewExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /AnimatedWaveViewExample.xcodeproj/xcuserdata/jwi175.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | AnimatedWaveViewExample.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /AnimatedWaveViewExample/AnimatedWaveView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AnimatedWaveView.swift 3 | // AnimatedWaveViewExample 4 | // 5 | // Created by Wilkin, Jason on 3/2/18. 6 | // Copyright © 2018 Nike. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import UIKit 11 | import CoreMotion 12 | 13 | public class AnimatedWaveView: UIView { 14 | 15 | // MARK: - Attributes 16 | 17 | // 7px between each wave 18 | private let waveIntervals: CGFloat = 7 19 | 20 | // Timing ratio is 40 seconds for a diameter of 667 21 | private let timingRatio: CFTimeInterval = 40.0 / 667.0 22 | 23 | // Scale of the final path's bounds in terms of the view's bounds 24 | private let scaleFactor: CGFloat = 1.75 25 | 26 | // CAAnimation Key 27 | private let waveAnimationKey = "wave_animation_key" 28 | 29 | // Starting rect 30 | private let baseRect = CGRect(x: 0, y: 0, width: 25, height: 25) 31 | 32 | // Animated radial gradient 33 | private var gradientLayer = RadialGradientLayer() 34 | 35 | // Parent maskLayer (contains all wave shapes) 36 | private var maskLayer = CALayer() 37 | 38 | // CMMotion 39 | private let motionManager = CMMotionManager() 40 | 41 | // Default gradient colors 42 | private var gradientColors: [UIColor] = [ 43 | UIColor(red: 1, green: 1, blue: 1, alpha: 0.80), 44 | UIColor(red: 1, green: 1, blue: 1, alpha: 0.50), 45 | UIColor(red: 1, green: 1, blue: 1, alpha: 0.20), 46 | UIColor(red: 1, green: 1, blue: 1, alpha: 0.02), 47 | UIColor(red: 1, green: 1, blue: 1, alpha: 0.02) 48 | ] 49 | 50 | // Cached initial and final paths for the waves 51 | private let initialPath: UIBezierPath = PathBuilder.buildStar() 52 | private var finalPath: UIBezierPath = PathBuilder.buildStar() 53 | 54 | // Update the final path if a frame change is detected 55 | public override var frame: CGRect { 56 | didSet { 57 | self.finalPath = calculateFinalPath() 58 | } 59 | } 60 | 61 | // MARK: - Lifecycle 62 | 63 | public override init(frame: CGRect) { 64 | super.init(frame: frame) 65 | self.finalPath = calculateFinalPath() 66 | self.clipsToBounds = true 67 | 68 | NotificationCenter.default.addObserver(self, selector: #selector(willEnterForeground(sender:)), name: .UIApplicationWillEnterForeground, object: nil) 69 | NotificationCenter.default.addObserver(self, selector: #selector(didEnterBackground(sender:)), name: .UIApplicationDidEnterBackground, object: nil) 70 | } 71 | 72 | required public init?(coder aDecoder: NSCoder) { 73 | fatalError("init(coder:) has not been implemented") 74 | } 75 | 76 | deinit { 77 | motionManager.stopDeviceMotionUpdates() 78 | NotificationCenter.default.removeObserver(self) 79 | } 80 | 81 | 82 | @objc func willEnterForeground(sender: Notification) { 83 | trackMotion() 84 | } 85 | 86 | @objc func didEnterBackground(sender: Notification) { 87 | motionManager.stopDeviceMotionUpdates() 88 | } 89 | 90 | // MARK: - Public methods 91 | 92 | public func makeWaves() { 93 | let waves = buildWaves() 94 | let maskLayer = CALayer() 95 | maskLayer.backgroundColor = UIColor.clear.cgColor 96 | waves.forEach({ maskLayer.addSublayer($0) }) 97 | addGradientLayer(withMask: maskLayer) 98 | trackMotion() 99 | } 100 | 101 | public func setGradientColors(_ colors: [UIColor]) { 102 | self.gradientColors = colors 103 | } 104 | 105 | 106 | // MARK: - Device Motion 107 | 108 | private func trackMotion() { 109 | if motionManager.isDeviceMotionAvailable { 110 | // Set how often the motion call back will trigger (in seconds) 111 | motionManager.deviceMotionUpdateInterval = 2.0 / 60.0 112 | let motionQueue = OperationQueue() 113 | motionManager.startDeviceMotionUpdates(to: motionQueue, withHandler: { [weak self] (data: CMDeviceMotion?, error: Error?) in 114 | guard let data = data else { return } 115 | // Move the gradient to a new position 116 | self?.moveGradient(gravityX: data.gravity.x, gravityY: data.gravity.y) 117 | }) 118 | } 119 | } 120 | 121 | // MARK: - Gradient 122 | 123 | private func addGradientLayer(withMask maskLayer: CALayer) { 124 | let colors = gradientColors.map({ $0.cgColor }) 125 | gradientLayer = RadialGradientLayer(colors: colors, center: self.center) 126 | gradientLayer.mask = maskLayer 127 | gradientLayer.frame = self.frame 128 | gradientLayer.bounds = self.bounds 129 | self.layer.addSublayer(gradientLayer) 130 | } 131 | 132 | private func moveGradient(gravityX: Double, gravityY: Double) { 133 | DispatchQueue.main.async { 134 | // Use gravity as a percentage of the view's vertical/horizonal bounds to calculate new x & y 135 | let x = (CGFloat(gravityX + 1) * self.bounds.width) / 2 136 | let y = (CGFloat(-gravityY + 1) * self.bounds.height) / 2 137 | // Update gradient center position 138 | self.gradientLayer.center = CGPoint(x: x, y: y) 139 | self.gradientLayer.setNeedsDisplay() 140 | } 141 | } 142 | 143 | // MARK: - Waves 144 | 145 | private func buildScaleTransform() -> CGAffineTransform { 146 | // Grab initial and final shape diameter 147 | let initialDiameter = self.initialPath.bounds.height 148 | let finalDiameter = self.frame.height 149 | // Calculate the factor by which to scale the shape. 150 | let transformScaleFactor = finalDiameter / initialDiameter * scaleFactor 151 | // Build the transform 152 | return CGAffineTransform(scaleX: transformScaleFactor, y: transformScaleFactor) 153 | } 154 | 155 | private func calculateFinalPath() -> UIBezierPath { 156 | let path = PathBuilder.buildStar() 157 | let scaleTransform = buildScaleTransform() 158 | path.apply(scaleTransform) 159 | return path 160 | } 161 | 162 | private func buildWaves() -> [CAShapeLayer] { 163 | // Get the greater value of width or height 164 | let diameter = self.bounds.width > self.bounds.height ? self.bounds.width : self.bounds.height 165 | 166 | // Calculate radus substracting the initial starting rect 167 | let radius = (diameter - baseRect.width) / 2 168 | 169 | // Divide radius up by each wave 170 | let numberOfWaves = Int(radius / waveIntervals) 171 | 172 | // Duration needs to change based on diameter so that the animation speed is the same for any view size 173 | let animationDuration = timingRatio * Double(diameter) 174 | 175 | var waves: [CAShapeLayer] = [] 176 | for i in 0 ..< numberOfWaves { 177 | let timeOffset = Double(i) * (animationDuration / Double(numberOfWaves)) 178 | let wave = self.buildAnimatedWave(timeOffset: timeOffset, duration: animationDuration) 179 | waves.append(wave) 180 | } 181 | 182 | return waves 183 | } 184 | 185 | private func buildAnimatedWave(timeOffset: CFTimeInterval, duration: CFTimeInterval) -> CAShapeLayer { 186 | let waveLayer = self.buildWave(rect: baseRect, path: initialPath.cgPath) 187 | self.animateWave(waveLayer: waveLayer, duration: duration, offset: timeOffset) 188 | return waveLayer 189 | } 190 | 191 | private func buildWave(rect: CGRect, path: CGPath) -> CAShapeLayer { 192 | let waveLayer = CAShapeLayer() 193 | waveLayer.bounds = rect 194 | waveLayer.frame = rect 195 | waveLayer.position = self.center 196 | waveLayer.strokeColor = UIColor.black.cgColor 197 | waveLayer.fillColor = UIColor.clear.cgColor 198 | waveLayer.lineWidth = 2.0 199 | waveLayer.path = path 200 | waveLayer.strokeStart = 0 201 | waveLayer.strokeEnd = 1 202 | return waveLayer 203 | } 204 | 205 | private func animateWave(waveLayer: CAShapeLayer, duration: CFTimeInterval, offset: CFTimeInterval) { 206 | // Fade-in animation 207 | let fadeInAnimation = CABasicAnimation(keyPath: "opacity") 208 | fadeInAnimation.fromValue = 0 209 | fadeInAnimation.toValue = 0.9 210 | fadeInAnimation.duration = 0.5 211 | 212 | // Path animation 213 | let pathAnimation = CABasicAnimation(keyPath: "path") 214 | pathAnimation.fromValue = waveLayer.path 215 | pathAnimation.toValue = finalPath.cgPath 216 | 217 | // Bounds animation 218 | let boundsAnimation = CABasicAnimation(keyPath: "bounds") 219 | let scaleTransform = buildScaleTransform() 220 | boundsAnimation.fromValue = waveLayer.bounds 221 | boundsAnimation.toValue = waveLayer.bounds.applying(scaleTransform) 222 | 223 | // Animation Group 224 | let scaleWave = CAAnimationGroup() 225 | scaleWave.animations = [fadeInAnimation, boundsAnimation, pathAnimation] 226 | scaleWave.duration = duration 227 | scaleWave.isRemovedOnCompletion = false 228 | scaleWave.repeatCount = Float.infinity 229 | scaleWave.fillMode = kCAFillModeForwards 230 | scaleWave.timeOffset = offset 231 | waveLayer.add(scaleWave, forKey: waveAnimationKey) 232 | } 233 | } 234 | -------------------------------------------------------------------------------- /AnimatedWaveViewExample/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // AnimatedWaveViewExample 4 | // 5 | // Created by Wilkin, Jason on 3/2/18. 6 | // Copyright © 2018 Nike. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(_ application: UIApplication) { 23 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 24 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 25 | } 26 | 27 | func applicationDidEnterBackground(_ application: UIApplication) { 28 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | } 31 | 32 | func applicationWillEnterForeground(_ application: UIApplication) { 33 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 34 | } 35 | 36 | func applicationDidBecomeActive(_ application: UIApplication) { 37 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 38 | } 39 | 40 | func applicationWillTerminate(_ application: UIApplication) { 41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42 | } 43 | 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /AnimatedWaveViewExample/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | } 88 | ], 89 | "info" : { 90 | "version" : 1, 91 | "author" : "xcode" 92 | } 93 | } -------------------------------------------------------------------------------- /AnimatedWaveViewExample/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 | -------------------------------------------------------------------------------- /AnimatedWaveViewExample/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /AnimatedWaveViewExample/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 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | 35 | UISupportedInterfaceOrientations~ipad 36 | 37 | UIInterfaceOrientationPortrait 38 | UIInterfaceOrientationPortraitUpsideDown 39 | UIInterfaceOrientationLandscapeLeft 40 | UIInterfaceOrientationLandscapeRight 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /AnimatedWaveViewExample/PathBuilder.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PathBuilder.swift 3 | // AnimatedWaveViewExample 4 | // 5 | // Created by Wilkin, Jason on 3/2/18. 6 | // Copyright © 2018 Nike. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import UIKit 11 | 12 | struct PathBuilder { 13 | 14 | static func buildStar() -> UIBezierPath { 15 | let starPath = UIBezierPath() 16 | starPath.move(to: CGPoint(x: 12.5, y: 0)) 17 | starPath.addLine(to: CGPoint(x: 14.82, y: 5.37)) 18 | starPath.addLine(to: CGPoint(x: 19.85, y: 2.39)) 19 | starPath.addLine(to: CGPoint(x: 18.57, y: 8.09)) 20 | starPath.addLine(to: CGPoint(x: 24.39, y: 8.64)) 21 | starPath.addLine(to: CGPoint(x: 20, y: 12.5)) 22 | starPath.addLine(to: CGPoint(x: 24.39, y: 16.36)) 23 | starPath.addLine(to: CGPoint(x: 18.57, y: 16.91)) 24 | starPath.addLine(to: CGPoint(x: 19.85, y: 22.61)) 25 | starPath.addLine(to: CGPoint(x: 14.82, y: 19.63)) 26 | starPath.addLine(to: CGPoint(x: 12.5, y: 25)) 27 | starPath.addLine(to: CGPoint(x: 10.18, y: 19.63)) 28 | starPath.addLine(to: CGPoint(x: 5.15, y: 22.61)) 29 | starPath.addLine(to: CGPoint(x: 6.43, y: 16.91)) 30 | starPath.addLine(to: CGPoint(x: 0.61, y: 16.36)) 31 | starPath.addLine(to: CGPoint(x: 5, y: 12.5)) 32 | starPath.addLine(to: CGPoint(x: 0.61, y: 8.64)) 33 | starPath.addLine(to: CGPoint(x: 6.43, y: 8.09)) 34 | starPath.addLine(to: CGPoint(x: 5.15, y: 2.39)) 35 | starPath.addLine(to: CGPoint(x: 10.18, y: 5.37)) 36 | starPath.close() 37 | return starPath 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /AnimatedWaveViewExample/RadialGradientLayer.swift: -------------------------------------------------------------------------------- 1 | // 2 | // RadialGradientLayer.swift 3 | // AnimatedWaveViewExample 4 | // 5 | // Created by Wilkin, Jason on 3/2/18. 6 | // Copyright © 2018 Nike. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import UIKit 11 | 12 | class RadialGradientLayer: CALayer { 13 | 14 | var colors: [CGColor] = [] 15 | var center: CGPoint = CGPoint.zero 16 | 17 | override init() { 18 | super.init() 19 | needsDisplayOnBoundsChange = true 20 | } 21 | 22 | init(colors: [CGColor], center: CGPoint) { 23 | self.colors = colors 24 | self.center = center 25 | super.init() 26 | } 27 | 28 | required init(coder aDecoder: NSCoder) { 29 | super.init() 30 | } 31 | 32 | override func draw(in ctx: CGContext) { 33 | ctx.saveGState() 34 | let colorSpace = CGColorSpaceCreateDeviceRGB() 35 | 36 | // Create a range of locations (CGFloats) from 0-1 for each color 37 | let step: CGFloat = 1.0 / CGFloat(colors.count) 38 | var locations = [CGFloat]() 39 | for i in 0 ..< colors.count { 40 | locations.append(CGFloat(i) * step) 41 | } 42 | 43 | // Create the CGGradient 44 | guard let gradient = CGGradient(colorsSpace: colorSpace, colors: colors as CFArray, locations: locations) else { 45 | ctx.restoreGState() 46 | return 47 | } 48 | let gradRadius = min(self.bounds.size.width, self.bounds.size.height) 49 | // Draw the radial gradient in the context, starting at the center and ending at view bounds 50 | ctx.drawRadialGradient(gradient, startCenter: center, startRadius: 0.0, endCenter: center, endRadius: gradRadius, options: []) 51 | ctx.restoreGState() 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /AnimatedWaveViewExample/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // AnimatedWaveViewExample 4 | // 5 | // Created by Wilkin, Jason on 3/2/18. 6 | // Copyright © 2018 Nike. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ViewController: UIViewController { 12 | 13 | var waveView: AnimatedWaveView? 14 | 15 | override func viewDidLoad() { 16 | super.viewDidLoad() 17 | self.view.backgroundColor = UIColor.blue 18 | buildWaveView() 19 | } 20 | 21 | func buildWaveView() { 22 | let animatedWaveView = AnimatedWaveView(frame: self.view.bounds) 23 | self.view.addSubview(animatedWaveView) 24 | waveView = animatedWaveView 25 | } 26 | 27 | override func viewDidAppear(_ animated: Bool) { 28 | super.viewDidAppear(animated) 29 | waveView?.makeWaves() 30 | } 31 | 32 | override func didReceiveMemoryWarning() { 33 | super.didReceiveMemoryWarning() 34 | // Dispose of any resources that can be recreated. 35 | } 36 | 37 | override var prefersStatusBarHidden: Bool { 38 | return true 39 | } 40 | 41 | override var supportedInterfaceOrientations: UIInterfaceOrientationMask { 42 | return .portrait 43 | } 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /AnimatedWaveViewExampleTests/AnimatedWaveViewExampleTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AnimatedWaveViewExampleTests.swift 3 | // AnimatedWaveViewExampleTests 4 | // 5 | // Created by Wilkin, Jason on 3/2/18. 6 | // Copyright © 2018 Nike. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | @testable import AnimatedWaveViewExample 11 | 12 | class AnimatedWaveViewExampleTests: XCTestCase { 13 | 14 | override func setUp() { 15 | super.setUp() 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | } 18 | 19 | override func tearDown() { 20 | // Put teardown code here. This method is called after the invocation of each test method in the class. 21 | super.tearDown() 22 | } 23 | 24 | func testExample() { 25 | // This is an example of a functional test case. 26 | // Use XCTAssert and related functions to verify your tests produce the correct results. 27 | } 28 | 29 | func testPerformanceExample() { 30 | // This is an example of a performance test case. 31 | self.measure { 32 | // Put the code you want to measure the time of here. 33 | } 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /AnimatedWaveViewExampleTests/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 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /AnimatedWaveViewExampleUITests/AnimatedWaveViewExampleUITests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AnimatedWaveViewExampleUITests.swift 3 | // AnimatedWaveViewExampleUITests 4 | // 5 | // Created by Wilkin, Jason on 3/2/18. 6 | // Copyright © 2018 Nike. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | 11 | class AnimatedWaveViewExampleUITests: XCTestCase { 12 | 13 | override func setUp() { 14 | super.setUp() 15 | 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | 18 | // In UI tests it is usually best to stop immediately when a failure occurs. 19 | continueAfterFailure = false 20 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 21 | XCUIApplication().launch() 22 | 23 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 24 | } 25 | 26 | override func tearDown() { 27 | // Put teardown code here. This method is called after the invocation of each test method in the class. 28 | super.tearDown() 29 | } 30 | 31 | func testExample() { 32 | // Use recording to get started writing UI tests. 33 | // Use XCTAssert and related functions to verify your tests produce the correct results. 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /AnimatedWaveViewExampleUITests/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 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Jason Wilkin 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 | # AnimatedWaveView 2 | 3 | [![Platform](https://img.shields.io/cocoapods/p/TableViewTools.svg?style=flat)](http://cocoapods.org/pods/LFAlertController) 4 | [![Swift Version](https://img.shields.io/badge/swift-4.0-orange.svg)](https://swift.org/) 5 | 6 | A example project for AnimatedWaveView: an interactive wave animation view built in Swift. Companion project to the blog post: https://medium.com/s23nyc-tech/prototyping-animations-in-swift-97a9cfb1f41b 7 | 8 | --- 9 | 10 | ![alt text](https://github.com/j-wilkin/AnimatedWaveView/blob/master/animatedwaves.gif "Animated Waves") 11 | 12 | --- 13 | 14 | ## Requirements 15 | 16 | - iOS 10.0+ 17 | - Xcode 9.0+ 18 | 19 | ## Authors 20 | 21 | - Jason Wilkin 22 | 23 | ## License 24 | 25 | [MIT licensed](LICENSE) 26 | -------------------------------------------------------------------------------- /animatedwaves.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/j-wilkin/AnimatedWaveView/ba7dd03b8e6af278d498eeb38f21deee693e045d/animatedwaves.gif --------------------------------------------------------------------------------