├── .gitignore ├── LICENSE ├── MarchingLayer.podspec ├── MarchingLayer.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcuserdata │ └── Cem.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist ├── MarchingLayer ├── AppDelegate.swift ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ ├── Contents.json │ ├── sheet1.imageset │ │ ├── Contents.json │ │ ├── sheet1.png │ │ ├── sheet1@2x.png │ │ └── sheet1@3x.png │ ├── sheet10.imageset │ │ ├── Contents.json │ │ ├── sheet10.png │ │ ├── sheet10@2x.png │ │ └── sheet10@3x.png │ ├── sheet12.imageset │ │ ├── Contents.json │ │ ├── sheet12.png │ │ ├── sheet12@2x.png │ │ └── sheet12@3x.png │ ├── sheet14.imageset │ │ ├── Contents.json │ │ ├── sheet14.png │ │ ├── sheet14@2x.png │ │ └── sheet14@3x.png │ ├── sheet15.imageset │ │ ├── Contents.json │ │ ├── sheet15.png │ │ ├── sheet15@2x.png │ │ └── sheet15@3x.png │ ├── sheet2.imageset │ │ ├── Contents.json │ │ ├── sheet2.png │ │ ├── sheet2@2x.png │ │ └── sheet2@3x.png │ ├── sheet3.imageset │ │ ├── Contents.json │ │ ├── sheet3.png │ │ ├── sheet3@2x.png │ │ └── sheet3@3x.png │ ├── sheet4.imageset │ │ ├── Contents.json │ │ ├── sheet4.png │ │ ├── sheet4@2x.png │ │ └── sheet4@3x.png │ ├── sheet5.imageset │ │ ├── Contents.json │ │ ├── sheet5.png │ │ ├── sheet5@2x.png │ │ └── sheet5@3x.png │ ├── sheet6.imageset │ │ ├── Contents.json │ │ ├── sheet6.png │ │ ├── sheet6@2x.png │ │ └── sheet6@3x.png │ ├── sheet7.imageset │ │ ├── Contents.json │ │ ├── sheet7.png │ │ ├── sheet7@2x.png │ │ └── sheet7@3x.png │ ├── sheet8.imageset │ │ ├── Contents.json │ │ ├── sheet8.png │ │ ├── sheet8@2x.png │ │ └── sheet8@3x.png │ └── sheet9.imageset │ │ ├── Contents.json │ │ ├── sheet9.png │ │ ├── sheet9@2x.png │ │ └── sheet9@3x.png ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Info.plist ├── MarchingLayer.swift └── ViewController.swift ├── README.md └── demo.gif /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.gitignore.io/api/swift,xcode 3 | 4 | ### Swift ### 5 | # Xcode 6 | # 7 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 8 | 9 | ## Build generated 10 | build/ 11 | DerivedData/ 12 | 13 | ## Various settings 14 | *.pbxuser 15 | !default.pbxuser 16 | *.mode1v3 17 | !default.mode1v3 18 | *.mode2v3 19 | !default.mode2v3 20 | *.perspectivev3 21 | !default.perspectivev3 22 | xcuserdata/ 23 | 24 | ## Other 25 | *.moved-aside 26 | *.xcuserstate 27 | 28 | ## Obj-C/Swift specific 29 | *.hmap 30 | *.ipa 31 | *.dSYM.zip 32 | *.dSYM 33 | 34 | ## Playgrounds 35 | timeline.xctimeline 36 | playground.xcworkspace 37 | 38 | # Swift Package Manager 39 | # 40 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 41 | # Packages/ 42 | .build/ 43 | 44 | # CocoaPods 45 | # 46 | # We recommend against adding the Pods directory to your .gitignore. However 47 | # you should judge for yourself, the pros and cons are mentioned at: 48 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 49 | # 50 | Pods/ 51 | 52 | # Carthage 53 | # 54 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 55 | Carthage/Checkouts 56 | 57 | Carthage/Build 58 | 59 | # fastlane 60 | # 61 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 62 | # screenshots whenever they are needed. 63 | # For more information about the recommended setup visit: 64 | # https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md 65 | 66 | fastlane/report.xml 67 | fastlane/Preview.html 68 | fastlane/screenshots 69 | fastlane/test_output 70 | 71 | 72 | ### Xcode ### 73 | # Xcode 74 | # 75 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 76 | 77 | ## Build generated 78 | 79 | ## Various settings 80 | 81 | ## Other 82 | *.xccheckout 83 | *.xcscmblueprint 84 | 85 | # Docs 86 | docs/ 87 | 88 | # End of https://www.gitignore.io/api/swift,xcode 89 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (C) 2017, Cem Olcay 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a 4 | copy of this software and associated documentation files (the "Software"), 5 | to deal in the Software without restriction, including without limitation 6 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | and/or sell copies of the Software, and to permit persons to whom the 8 | Software is furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19 | DEALINGS IN THE SOFTWARE. 20 | 21 | -------------------------------------------------------------------------------- /MarchingLayer.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # Be sure to run `pod spec lint MarchingLayer.podspec' to ensure this is a 3 | # valid spec and to remove all comments including this before submitting the spec. 4 | # 5 | # To learn more about Podspec attributes see http://docs.cocoapods.org/specification.html 6 | # To see working Podspecs in the CocoaPods repo see https://github.com/CocoaPods/Specs/ 7 | # 8 | 9 | Pod::Spec.new do |s| 10 | 11 | # ――― Spec Metadata ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 12 | # 13 | # These will help people to find your library, and whilst it 14 | # can feel like a chore to fill in it's definitely to your advantage. The 15 | # summary should be tweet-length, and the description more in depth. 16 | # 17 | 18 | s.name = "MarchingLayer" 19 | s.version = "0.0.1" 20 | s.summary = "Randomly fills layer with sprites and move them in any direction and speed you want." 21 | 22 | # This description is used to generate tags and improve search results. 23 | # * Think: What does it do? Why did you write it? What is the focus? 24 | # * Try to keep it short, snappy and to the point. 25 | # * Write the description between the DESC delimiters below. 26 | # * Finally, don't worry about the indent, CocoaPods strips it! 27 | s.description = <<-DESC 28 | MarchingLayer 29 | ==== 30 | 31 | Randomly fills layer with sprites and move them in any direction and speed you want. 32 | 33 | Demo 34 | ---- 35 | 36 | ![alt tag](https://github.com/cemolcay/MarchingLayer/raw/master/demo.gif) 37 | 38 | Requirements 39 | ---- 40 | 41 | * Swift 4.0+ 42 | * iOS 8.0+ 43 | * tvOS 9.0+ 44 | 45 | Install 46 | ---- 47 | 48 | ``` 49 | pod 'MarchingLayer' 50 | ``` 51 | 52 | Usage 53 | ---- 54 | 55 | Create and add a `MarchingLayer` into your view. 56 | Set `sprites` property with images you want to show in layer. 57 | Set `animationDirection` to `up`, `down`, `left` or `right`. 58 | Set `animationSpeed` to change animation speed. 59 | Call `startAnimation()` to start, `stopAnimation()` to stop marching animation. 60 | DESC 61 | 62 | s.homepage = "https://github.com/cemolcay/MarchingLayer" 63 | # s.screenshots = "www.example.com/screenshots_1.gif", "www.example.com/screenshots_2.gif" 64 | 65 | 66 | # ――― Spec License ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 67 | # 68 | # Licensing your code is important. See http://choosealicense.com for more info. 69 | # CocoaPods will detect a license file if there is a named LICENSE* 70 | # Popular ones are 'MIT', 'BSD' and 'Apache License, Version 2.0'. 71 | # 72 | 73 | s.license = "MIT" 74 | # s.license = { :type => "MIT", :file => "FILE_LICENSE" } 75 | 76 | 77 | # ――― Author Metadata ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 78 | # 79 | # Specify the authors of the library, with email addresses. Email addresses 80 | # of the authors are extracted from the SCM log. E.g. $ git log. CocoaPods also 81 | # accepts just a name if you'd rather not provide an email address. 82 | # 83 | # Specify a social_media_url where others can refer to, for example a twitter 84 | # profile URL. 85 | # 86 | 87 | s.author = { "cemolcay" => "ccemolcay@gmail.com" } 88 | # Or just: s.author = "cemolcay" 89 | # s.authors = { "cemolcay" => "ccemolcay@gmail.com" } 90 | s.social_media_url = "http://twitter.com/cemolcay" 91 | 92 | # ――― Platform Specifics ――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 93 | # 94 | # If this Pod runs only on iOS or OS X, then specify the platform and 95 | # the deployment target. You can optionally include the target after the platform. 96 | # 97 | 98 | # s.platform = :ios 99 | # s.platform = :ios, "5.0" 100 | 101 | # When using multiple platforms 102 | s.ios.deployment_target = "8.0" 103 | # s.osx.deployment_target = "10.7" 104 | # s.watchos.deployment_target = "2.0" 105 | s.tvos.deployment_target = "9.0" 106 | 107 | 108 | # ――― Source Location ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 109 | # 110 | # Specify the location from where the source should be retrieved. 111 | # Supports git, hg, bzr, svn and HTTP. 112 | # 113 | 114 | s.source = { :git => "https://github.com/cemolcay/MarchingLayer.git", :tag => "#{s.version}" } 115 | 116 | 117 | # ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 118 | # 119 | # CocoaPods is smart about how it includes source code. For source files 120 | # giving a folder will include any swift, h, m, mm, c & cpp files. 121 | # For header files it will include any header in the folder. 122 | # Not including the public_header_files will make all headers public. 123 | # 124 | 125 | s.source_files = "MarchingLayer/MarchingLayer.swift" 126 | # s.exclude_files = "Classes/Exclude" 127 | 128 | # s.public_header_files = "Classes/**/*.h" 129 | 130 | 131 | # ――― Resources ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 132 | # 133 | # A list of resources included with the Pod. These are copied into the 134 | # target bundle with a build phase script. Anything else will be cleaned. 135 | # You can preserve files from being cleaned, please don't preserve 136 | # non-essential files like tests, examples and documentation. 137 | # 138 | 139 | # s.resource = "icon.png" 140 | # s.resources = "Resources/*.png" 141 | 142 | # s.preserve_paths = "FilesToSave", "MoreFilesToSave" 143 | 144 | 145 | # ――― Project Linking ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 146 | # 147 | # Link your library with frameworks, or libraries. Libraries do not include 148 | # the lib prefix of their name. 149 | # 150 | 151 | # s.framework = "SomeFramework" 152 | # s.frameworks = "SomeFramework", "AnotherFramework" 153 | 154 | # s.library = "iconv" 155 | # s.libraries = "iconv", "xml2" 156 | 157 | 158 | # ――― Project Settings ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 159 | # 160 | # If your library depends on compiler flags you can set them in the xcconfig hash 161 | # where they will only apply to your library. If you depend on other Podspecs 162 | # you can include multiple dependencies to ensure it works. 163 | 164 | s.requires_arc = true 165 | 166 | # s.xcconfig = { "HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2" } 167 | # s.dependency "JSONKit", "~> 1.4" 168 | 169 | end 170 | -------------------------------------------------------------------------------- /MarchingLayer.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 48; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | B2BDCAE01FB88C6E00FE3DA7 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B2BDCADF1FB88C6E00FE3DA7 /* AppDelegate.swift */; }; 11 | B2BDCAE21FB88C6E00FE3DA7 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B2BDCAE11FB88C6E00FE3DA7 /* ViewController.swift */; }; 12 | B2BDCAE51FB88C6E00FE3DA7 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B2BDCAE31FB88C6E00FE3DA7 /* Main.storyboard */; }; 13 | B2BDCAE71FB88C6E00FE3DA7 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B2BDCAE61FB88C6E00FE3DA7 /* Assets.xcassets */; }; 14 | B2BDCAEA1FB88C6E00FE3DA7 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B2BDCAE81FB88C6E00FE3DA7 /* LaunchScreen.storyboard */; }; 15 | B2BDCAF21FB88C7F00FE3DA7 /* MarchingLayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = B2BDCAF11FB88C7F00FE3DA7 /* MarchingLayer.swift */; }; 16 | /* End PBXBuildFile section */ 17 | 18 | /* Begin PBXFileReference section */ 19 | B2BDCADC1FB88C6E00FE3DA7 /* MarchingLayer.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MarchingLayer.app; sourceTree = BUILT_PRODUCTS_DIR; }; 20 | B2BDCADF1FB88C6E00FE3DA7 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 21 | B2BDCAE11FB88C6E00FE3DA7 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 22 | B2BDCAE41FB88C6E00FE3DA7 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 23 | B2BDCAE61FB88C6E00FE3DA7 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 24 | B2BDCAE91FB88C6E00FE3DA7 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 25 | B2BDCAEB1FB88C6E00FE3DA7 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 26 | B2BDCAF11FB88C7F00FE3DA7 /* MarchingLayer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MarchingLayer.swift; sourceTree = ""; }; 27 | /* End PBXFileReference section */ 28 | 29 | /* Begin PBXFrameworksBuildPhase section */ 30 | B2BDCAD91FB88C6E00FE3DA7 /* Frameworks */ = { 31 | isa = PBXFrameworksBuildPhase; 32 | buildActionMask = 2147483647; 33 | files = ( 34 | ); 35 | runOnlyForDeploymentPostprocessing = 0; 36 | }; 37 | /* End PBXFrameworksBuildPhase section */ 38 | 39 | /* Begin PBXGroup section */ 40 | B2BDCAD31FB88C6E00FE3DA7 = { 41 | isa = PBXGroup; 42 | children = ( 43 | B2BDCADE1FB88C6E00FE3DA7 /* MarchingLayer */, 44 | B2BDCADD1FB88C6E00FE3DA7 /* Products */, 45 | ); 46 | sourceTree = ""; 47 | }; 48 | B2BDCADD1FB88C6E00FE3DA7 /* Products */ = { 49 | isa = PBXGroup; 50 | children = ( 51 | B2BDCADC1FB88C6E00FE3DA7 /* MarchingLayer.app */, 52 | ); 53 | name = Products; 54 | sourceTree = ""; 55 | }; 56 | B2BDCADE1FB88C6E00FE3DA7 /* MarchingLayer */ = { 57 | isa = PBXGroup; 58 | children = ( 59 | B2BDCADF1FB88C6E00FE3DA7 /* AppDelegate.swift */, 60 | B2BDCAE11FB88C6E00FE3DA7 /* ViewController.swift */, 61 | B2BDCAF11FB88C7F00FE3DA7 /* MarchingLayer.swift */, 62 | B2BDCAE31FB88C6E00FE3DA7 /* Main.storyboard */, 63 | B2BDCAE61FB88C6E00FE3DA7 /* Assets.xcassets */, 64 | B2BDCAE81FB88C6E00FE3DA7 /* LaunchScreen.storyboard */, 65 | B2BDCAEB1FB88C6E00FE3DA7 /* Info.plist */, 66 | ); 67 | path = MarchingLayer; 68 | sourceTree = ""; 69 | }; 70 | /* End PBXGroup section */ 71 | 72 | /* Begin PBXNativeTarget section */ 73 | B2BDCADB1FB88C6E00FE3DA7 /* MarchingLayer */ = { 74 | isa = PBXNativeTarget; 75 | buildConfigurationList = B2BDCAEE1FB88C6E00FE3DA7 /* Build configuration list for PBXNativeTarget "MarchingLayer" */; 76 | buildPhases = ( 77 | B2BDCAD81FB88C6E00FE3DA7 /* Sources */, 78 | B2BDCAD91FB88C6E00FE3DA7 /* Frameworks */, 79 | B2BDCADA1FB88C6E00FE3DA7 /* Resources */, 80 | ); 81 | buildRules = ( 82 | ); 83 | dependencies = ( 84 | ); 85 | name = MarchingLayer; 86 | productName = MarchingLayer; 87 | productReference = B2BDCADC1FB88C6E00FE3DA7 /* MarchingLayer.app */; 88 | productType = "com.apple.product-type.application"; 89 | }; 90 | /* End PBXNativeTarget section */ 91 | 92 | /* Begin PBXProject section */ 93 | B2BDCAD41FB88C6E00FE3DA7 /* Project object */ = { 94 | isa = PBXProject; 95 | attributes = { 96 | LastSwiftUpdateCheck = 0910; 97 | LastUpgradeCheck = 0910; 98 | ORGANIZATIONNAME = cemolcay; 99 | TargetAttributes = { 100 | B2BDCADB1FB88C6E00FE3DA7 = { 101 | CreatedOnToolsVersion = 9.1; 102 | ProvisioningStyle = Automatic; 103 | }; 104 | }; 105 | }; 106 | buildConfigurationList = B2BDCAD71FB88C6E00FE3DA7 /* Build configuration list for PBXProject "MarchingLayer" */; 107 | compatibilityVersion = "Xcode 8.0"; 108 | developmentRegion = en; 109 | hasScannedForEncodings = 0; 110 | knownRegions = ( 111 | en, 112 | Base, 113 | ); 114 | mainGroup = B2BDCAD31FB88C6E00FE3DA7; 115 | productRefGroup = B2BDCADD1FB88C6E00FE3DA7 /* Products */; 116 | projectDirPath = ""; 117 | projectRoot = ""; 118 | targets = ( 119 | B2BDCADB1FB88C6E00FE3DA7 /* MarchingLayer */, 120 | ); 121 | }; 122 | /* End PBXProject section */ 123 | 124 | /* Begin PBXResourcesBuildPhase section */ 125 | B2BDCADA1FB88C6E00FE3DA7 /* Resources */ = { 126 | isa = PBXResourcesBuildPhase; 127 | buildActionMask = 2147483647; 128 | files = ( 129 | B2BDCAEA1FB88C6E00FE3DA7 /* LaunchScreen.storyboard in Resources */, 130 | B2BDCAE71FB88C6E00FE3DA7 /* Assets.xcassets in Resources */, 131 | B2BDCAE51FB88C6E00FE3DA7 /* Main.storyboard in Resources */, 132 | ); 133 | runOnlyForDeploymentPostprocessing = 0; 134 | }; 135 | /* End PBXResourcesBuildPhase section */ 136 | 137 | /* Begin PBXSourcesBuildPhase section */ 138 | B2BDCAD81FB88C6E00FE3DA7 /* Sources */ = { 139 | isa = PBXSourcesBuildPhase; 140 | buildActionMask = 2147483647; 141 | files = ( 142 | B2BDCAF21FB88C7F00FE3DA7 /* MarchingLayer.swift in Sources */, 143 | B2BDCAE21FB88C6E00FE3DA7 /* ViewController.swift in Sources */, 144 | B2BDCAE01FB88C6E00FE3DA7 /* AppDelegate.swift in Sources */, 145 | ); 146 | runOnlyForDeploymentPostprocessing = 0; 147 | }; 148 | /* End PBXSourcesBuildPhase section */ 149 | 150 | /* Begin PBXVariantGroup section */ 151 | B2BDCAE31FB88C6E00FE3DA7 /* Main.storyboard */ = { 152 | isa = PBXVariantGroup; 153 | children = ( 154 | B2BDCAE41FB88C6E00FE3DA7 /* Base */, 155 | ); 156 | name = Main.storyboard; 157 | sourceTree = ""; 158 | }; 159 | B2BDCAE81FB88C6E00FE3DA7 /* LaunchScreen.storyboard */ = { 160 | isa = PBXVariantGroup; 161 | children = ( 162 | B2BDCAE91FB88C6E00FE3DA7 /* Base */, 163 | ); 164 | name = LaunchScreen.storyboard; 165 | sourceTree = ""; 166 | }; 167 | /* End PBXVariantGroup section */ 168 | 169 | /* Begin XCBuildConfiguration section */ 170 | B2BDCAEC1FB88C6E00FE3DA7 /* Debug */ = { 171 | isa = XCBuildConfiguration; 172 | buildSettings = { 173 | ALWAYS_SEARCH_USER_PATHS = NO; 174 | CLANG_ANALYZER_NONNULL = YES; 175 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 176 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 177 | CLANG_CXX_LIBRARY = "libc++"; 178 | CLANG_ENABLE_MODULES = YES; 179 | CLANG_ENABLE_OBJC_ARC = YES; 180 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 181 | CLANG_WARN_BOOL_CONVERSION = YES; 182 | CLANG_WARN_COMMA = YES; 183 | CLANG_WARN_CONSTANT_CONVERSION = YES; 184 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 185 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 186 | CLANG_WARN_EMPTY_BODY = YES; 187 | CLANG_WARN_ENUM_CONVERSION = YES; 188 | CLANG_WARN_INFINITE_RECURSION = YES; 189 | CLANG_WARN_INT_CONVERSION = YES; 190 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 191 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 192 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 193 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 194 | CLANG_WARN_STRICT_PROTOTYPES = YES; 195 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 196 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 197 | CLANG_WARN_UNREACHABLE_CODE = YES; 198 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 199 | CODE_SIGN_IDENTITY = "iPhone Developer"; 200 | COPY_PHASE_STRIP = NO; 201 | DEBUG_INFORMATION_FORMAT = dwarf; 202 | ENABLE_STRICT_OBJC_MSGSEND = YES; 203 | ENABLE_TESTABILITY = YES; 204 | GCC_C_LANGUAGE_STANDARD = gnu11; 205 | GCC_DYNAMIC_NO_PIC = NO; 206 | GCC_NO_COMMON_BLOCKS = YES; 207 | GCC_OPTIMIZATION_LEVEL = 0; 208 | GCC_PREPROCESSOR_DEFINITIONS = ( 209 | "DEBUG=1", 210 | "$(inherited)", 211 | ); 212 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 213 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 214 | GCC_WARN_UNDECLARED_SELECTOR = YES; 215 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 216 | GCC_WARN_UNUSED_FUNCTION = YES; 217 | GCC_WARN_UNUSED_VARIABLE = YES; 218 | IPHONEOS_DEPLOYMENT_TARGET = 11.1; 219 | MTL_ENABLE_DEBUG_INFO = YES; 220 | ONLY_ACTIVE_ARCH = YES; 221 | SDKROOT = iphoneos; 222 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 223 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 224 | }; 225 | name = Debug; 226 | }; 227 | B2BDCAED1FB88C6E00FE3DA7 /* Release */ = { 228 | isa = XCBuildConfiguration; 229 | buildSettings = { 230 | ALWAYS_SEARCH_USER_PATHS = NO; 231 | CLANG_ANALYZER_NONNULL = YES; 232 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 233 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 234 | CLANG_CXX_LIBRARY = "libc++"; 235 | CLANG_ENABLE_MODULES = YES; 236 | CLANG_ENABLE_OBJC_ARC = YES; 237 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 238 | CLANG_WARN_BOOL_CONVERSION = YES; 239 | CLANG_WARN_COMMA = YES; 240 | CLANG_WARN_CONSTANT_CONVERSION = YES; 241 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 242 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 243 | CLANG_WARN_EMPTY_BODY = YES; 244 | CLANG_WARN_ENUM_CONVERSION = YES; 245 | CLANG_WARN_INFINITE_RECURSION = YES; 246 | CLANG_WARN_INT_CONVERSION = YES; 247 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 248 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 249 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 250 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 251 | CLANG_WARN_STRICT_PROTOTYPES = YES; 252 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 253 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 254 | CLANG_WARN_UNREACHABLE_CODE = YES; 255 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 256 | CODE_SIGN_IDENTITY = "iPhone Developer"; 257 | COPY_PHASE_STRIP = NO; 258 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 259 | ENABLE_NS_ASSERTIONS = NO; 260 | ENABLE_STRICT_OBJC_MSGSEND = YES; 261 | GCC_C_LANGUAGE_STANDARD = gnu11; 262 | GCC_NO_COMMON_BLOCKS = YES; 263 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 264 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 265 | GCC_WARN_UNDECLARED_SELECTOR = YES; 266 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 267 | GCC_WARN_UNUSED_FUNCTION = YES; 268 | GCC_WARN_UNUSED_VARIABLE = YES; 269 | IPHONEOS_DEPLOYMENT_TARGET = 11.1; 270 | MTL_ENABLE_DEBUG_INFO = NO; 271 | SDKROOT = iphoneos; 272 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 273 | VALIDATE_PRODUCT = YES; 274 | }; 275 | name = Release; 276 | }; 277 | B2BDCAEF1FB88C6E00FE3DA7 /* Debug */ = { 278 | isa = XCBuildConfiguration; 279 | buildSettings = { 280 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 281 | CODE_SIGN_STYLE = Automatic; 282 | DEVELOPMENT_TEAM = 77Y3N48SNF; 283 | INFOPLIST_FILE = MarchingLayer/Info.plist; 284 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 285 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 286 | PRODUCT_BUNDLE_IDENTIFIER = com.cemolcay.MarchingLayer; 287 | PRODUCT_NAME = "$(TARGET_NAME)"; 288 | SWIFT_VERSION = 4.0; 289 | TARGETED_DEVICE_FAMILY = "1,2"; 290 | }; 291 | name = Debug; 292 | }; 293 | B2BDCAF01FB88C6E00FE3DA7 /* Release */ = { 294 | isa = XCBuildConfiguration; 295 | buildSettings = { 296 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 297 | CODE_SIGN_STYLE = Automatic; 298 | DEVELOPMENT_TEAM = 77Y3N48SNF; 299 | INFOPLIST_FILE = MarchingLayer/Info.plist; 300 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 301 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 302 | PRODUCT_BUNDLE_IDENTIFIER = com.cemolcay.MarchingLayer; 303 | PRODUCT_NAME = "$(TARGET_NAME)"; 304 | SWIFT_VERSION = 4.0; 305 | TARGETED_DEVICE_FAMILY = "1,2"; 306 | }; 307 | name = Release; 308 | }; 309 | /* End XCBuildConfiguration section */ 310 | 311 | /* Begin XCConfigurationList section */ 312 | B2BDCAD71FB88C6E00FE3DA7 /* Build configuration list for PBXProject "MarchingLayer" */ = { 313 | isa = XCConfigurationList; 314 | buildConfigurations = ( 315 | B2BDCAEC1FB88C6E00FE3DA7 /* Debug */, 316 | B2BDCAED1FB88C6E00FE3DA7 /* Release */, 317 | ); 318 | defaultConfigurationIsVisible = 0; 319 | defaultConfigurationName = Release; 320 | }; 321 | B2BDCAEE1FB88C6E00FE3DA7 /* Build configuration list for PBXNativeTarget "MarchingLayer" */ = { 322 | isa = XCConfigurationList; 323 | buildConfigurations = ( 324 | B2BDCAEF1FB88C6E00FE3DA7 /* Debug */, 325 | B2BDCAF01FB88C6E00FE3DA7 /* Release */, 326 | ); 327 | defaultConfigurationIsVisible = 0; 328 | defaultConfigurationName = Release; 329 | }; 330 | /* End XCConfigurationList section */ 331 | }; 332 | rootObject = B2BDCAD41FB88C6E00FE3DA7 /* Project object */; 333 | } 334 | -------------------------------------------------------------------------------- /MarchingLayer.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /MarchingLayer.xcodeproj/xcuserdata/Cem.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | MarchingLayer.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /MarchingLayer/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // MarchingLayer 4 | // 5 | // Created by Cem Olcay on 12.11.2017. 6 | // Copyright © 2017 cemolcay. 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 | -------------------------------------------------------------------------------- /MarchingLayer/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 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /MarchingLayer/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /MarchingLayer/Assets.xcassets/sheet1.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "sheet1.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "sheet1@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "sheet1@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /MarchingLayer/Assets.xcassets/sheet1.imageset/sheet1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cemolcay/MarchingLayer/641c8ff861162b6313926cc3848ef28ee020445d/MarchingLayer/Assets.xcassets/sheet1.imageset/sheet1.png -------------------------------------------------------------------------------- /MarchingLayer/Assets.xcassets/sheet1.imageset/sheet1@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cemolcay/MarchingLayer/641c8ff861162b6313926cc3848ef28ee020445d/MarchingLayer/Assets.xcassets/sheet1.imageset/sheet1@2x.png -------------------------------------------------------------------------------- /MarchingLayer/Assets.xcassets/sheet1.imageset/sheet1@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cemolcay/MarchingLayer/641c8ff861162b6313926cc3848ef28ee020445d/MarchingLayer/Assets.xcassets/sheet1.imageset/sheet1@3x.png -------------------------------------------------------------------------------- /MarchingLayer/Assets.xcassets/sheet10.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "sheet10.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "sheet10@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "sheet10@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /MarchingLayer/Assets.xcassets/sheet10.imageset/sheet10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cemolcay/MarchingLayer/641c8ff861162b6313926cc3848ef28ee020445d/MarchingLayer/Assets.xcassets/sheet10.imageset/sheet10.png -------------------------------------------------------------------------------- /MarchingLayer/Assets.xcassets/sheet10.imageset/sheet10@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cemolcay/MarchingLayer/641c8ff861162b6313926cc3848ef28ee020445d/MarchingLayer/Assets.xcassets/sheet10.imageset/sheet10@2x.png -------------------------------------------------------------------------------- /MarchingLayer/Assets.xcassets/sheet10.imageset/sheet10@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cemolcay/MarchingLayer/641c8ff861162b6313926cc3848ef28ee020445d/MarchingLayer/Assets.xcassets/sheet10.imageset/sheet10@3x.png -------------------------------------------------------------------------------- /MarchingLayer/Assets.xcassets/sheet12.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "sheet12.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "sheet12@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "sheet12@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /MarchingLayer/Assets.xcassets/sheet12.imageset/sheet12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cemolcay/MarchingLayer/641c8ff861162b6313926cc3848ef28ee020445d/MarchingLayer/Assets.xcassets/sheet12.imageset/sheet12.png -------------------------------------------------------------------------------- /MarchingLayer/Assets.xcassets/sheet12.imageset/sheet12@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cemolcay/MarchingLayer/641c8ff861162b6313926cc3848ef28ee020445d/MarchingLayer/Assets.xcassets/sheet12.imageset/sheet12@2x.png -------------------------------------------------------------------------------- /MarchingLayer/Assets.xcassets/sheet12.imageset/sheet12@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cemolcay/MarchingLayer/641c8ff861162b6313926cc3848ef28ee020445d/MarchingLayer/Assets.xcassets/sheet12.imageset/sheet12@3x.png -------------------------------------------------------------------------------- /MarchingLayer/Assets.xcassets/sheet14.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "sheet14.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "sheet14@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "sheet14@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /MarchingLayer/Assets.xcassets/sheet14.imageset/sheet14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cemolcay/MarchingLayer/641c8ff861162b6313926cc3848ef28ee020445d/MarchingLayer/Assets.xcassets/sheet14.imageset/sheet14.png -------------------------------------------------------------------------------- /MarchingLayer/Assets.xcassets/sheet14.imageset/sheet14@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cemolcay/MarchingLayer/641c8ff861162b6313926cc3848ef28ee020445d/MarchingLayer/Assets.xcassets/sheet14.imageset/sheet14@2x.png -------------------------------------------------------------------------------- /MarchingLayer/Assets.xcassets/sheet14.imageset/sheet14@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cemolcay/MarchingLayer/641c8ff861162b6313926cc3848ef28ee020445d/MarchingLayer/Assets.xcassets/sheet14.imageset/sheet14@3x.png -------------------------------------------------------------------------------- /MarchingLayer/Assets.xcassets/sheet15.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "sheet15.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "sheet15@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "sheet15@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /MarchingLayer/Assets.xcassets/sheet15.imageset/sheet15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cemolcay/MarchingLayer/641c8ff861162b6313926cc3848ef28ee020445d/MarchingLayer/Assets.xcassets/sheet15.imageset/sheet15.png -------------------------------------------------------------------------------- /MarchingLayer/Assets.xcassets/sheet15.imageset/sheet15@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cemolcay/MarchingLayer/641c8ff861162b6313926cc3848ef28ee020445d/MarchingLayer/Assets.xcassets/sheet15.imageset/sheet15@2x.png -------------------------------------------------------------------------------- /MarchingLayer/Assets.xcassets/sheet15.imageset/sheet15@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cemolcay/MarchingLayer/641c8ff861162b6313926cc3848ef28ee020445d/MarchingLayer/Assets.xcassets/sheet15.imageset/sheet15@3x.png -------------------------------------------------------------------------------- /MarchingLayer/Assets.xcassets/sheet2.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "sheet2.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "sheet2@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "sheet2@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /MarchingLayer/Assets.xcassets/sheet2.imageset/sheet2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cemolcay/MarchingLayer/641c8ff861162b6313926cc3848ef28ee020445d/MarchingLayer/Assets.xcassets/sheet2.imageset/sheet2.png -------------------------------------------------------------------------------- /MarchingLayer/Assets.xcassets/sheet2.imageset/sheet2@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cemolcay/MarchingLayer/641c8ff861162b6313926cc3848ef28ee020445d/MarchingLayer/Assets.xcassets/sheet2.imageset/sheet2@2x.png -------------------------------------------------------------------------------- /MarchingLayer/Assets.xcassets/sheet2.imageset/sheet2@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cemolcay/MarchingLayer/641c8ff861162b6313926cc3848ef28ee020445d/MarchingLayer/Assets.xcassets/sheet2.imageset/sheet2@3x.png -------------------------------------------------------------------------------- /MarchingLayer/Assets.xcassets/sheet3.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "sheet3.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "sheet3@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "sheet3@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /MarchingLayer/Assets.xcassets/sheet3.imageset/sheet3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cemolcay/MarchingLayer/641c8ff861162b6313926cc3848ef28ee020445d/MarchingLayer/Assets.xcassets/sheet3.imageset/sheet3.png -------------------------------------------------------------------------------- /MarchingLayer/Assets.xcassets/sheet3.imageset/sheet3@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cemolcay/MarchingLayer/641c8ff861162b6313926cc3848ef28ee020445d/MarchingLayer/Assets.xcassets/sheet3.imageset/sheet3@2x.png -------------------------------------------------------------------------------- /MarchingLayer/Assets.xcassets/sheet3.imageset/sheet3@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cemolcay/MarchingLayer/641c8ff861162b6313926cc3848ef28ee020445d/MarchingLayer/Assets.xcassets/sheet3.imageset/sheet3@3x.png -------------------------------------------------------------------------------- /MarchingLayer/Assets.xcassets/sheet4.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "sheet4.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "sheet4@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "sheet4@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /MarchingLayer/Assets.xcassets/sheet4.imageset/sheet4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cemolcay/MarchingLayer/641c8ff861162b6313926cc3848ef28ee020445d/MarchingLayer/Assets.xcassets/sheet4.imageset/sheet4.png -------------------------------------------------------------------------------- /MarchingLayer/Assets.xcassets/sheet4.imageset/sheet4@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cemolcay/MarchingLayer/641c8ff861162b6313926cc3848ef28ee020445d/MarchingLayer/Assets.xcassets/sheet4.imageset/sheet4@2x.png -------------------------------------------------------------------------------- /MarchingLayer/Assets.xcassets/sheet4.imageset/sheet4@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cemolcay/MarchingLayer/641c8ff861162b6313926cc3848ef28ee020445d/MarchingLayer/Assets.xcassets/sheet4.imageset/sheet4@3x.png -------------------------------------------------------------------------------- /MarchingLayer/Assets.xcassets/sheet5.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "sheet5.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "sheet5@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "sheet5@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /MarchingLayer/Assets.xcassets/sheet5.imageset/sheet5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cemolcay/MarchingLayer/641c8ff861162b6313926cc3848ef28ee020445d/MarchingLayer/Assets.xcassets/sheet5.imageset/sheet5.png -------------------------------------------------------------------------------- /MarchingLayer/Assets.xcassets/sheet5.imageset/sheet5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cemolcay/MarchingLayer/641c8ff861162b6313926cc3848ef28ee020445d/MarchingLayer/Assets.xcassets/sheet5.imageset/sheet5@2x.png -------------------------------------------------------------------------------- /MarchingLayer/Assets.xcassets/sheet5.imageset/sheet5@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cemolcay/MarchingLayer/641c8ff861162b6313926cc3848ef28ee020445d/MarchingLayer/Assets.xcassets/sheet5.imageset/sheet5@3x.png -------------------------------------------------------------------------------- /MarchingLayer/Assets.xcassets/sheet6.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "sheet6.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "sheet6@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "sheet6@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /MarchingLayer/Assets.xcassets/sheet6.imageset/sheet6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cemolcay/MarchingLayer/641c8ff861162b6313926cc3848ef28ee020445d/MarchingLayer/Assets.xcassets/sheet6.imageset/sheet6.png -------------------------------------------------------------------------------- /MarchingLayer/Assets.xcassets/sheet6.imageset/sheet6@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cemolcay/MarchingLayer/641c8ff861162b6313926cc3848ef28ee020445d/MarchingLayer/Assets.xcassets/sheet6.imageset/sheet6@2x.png -------------------------------------------------------------------------------- /MarchingLayer/Assets.xcassets/sheet6.imageset/sheet6@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cemolcay/MarchingLayer/641c8ff861162b6313926cc3848ef28ee020445d/MarchingLayer/Assets.xcassets/sheet6.imageset/sheet6@3x.png -------------------------------------------------------------------------------- /MarchingLayer/Assets.xcassets/sheet7.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "sheet7.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "sheet7@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "sheet7@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /MarchingLayer/Assets.xcassets/sheet7.imageset/sheet7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cemolcay/MarchingLayer/641c8ff861162b6313926cc3848ef28ee020445d/MarchingLayer/Assets.xcassets/sheet7.imageset/sheet7.png -------------------------------------------------------------------------------- /MarchingLayer/Assets.xcassets/sheet7.imageset/sheet7@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cemolcay/MarchingLayer/641c8ff861162b6313926cc3848ef28ee020445d/MarchingLayer/Assets.xcassets/sheet7.imageset/sheet7@2x.png -------------------------------------------------------------------------------- /MarchingLayer/Assets.xcassets/sheet7.imageset/sheet7@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cemolcay/MarchingLayer/641c8ff861162b6313926cc3848ef28ee020445d/MarchingLayer/Assets.xcassets/sheet7.imageset/sheet7@3x.png -------------------------------------------------------------------------------- /MarchingLayer/Assets.xcassets/sheet8.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "sheet8.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "sheet8@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "sheet8@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /MarchingLayer/Assets.xcassets/sheet8.imageset/sheet8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cemolcay/MarchingLayer/641c8ff861162b6313926cc3848ef28ee020445d/MarchingLayer/Assets.xcassets/sheet8.imageset/sheet8.png -------------------------------------------------------------------------------- /MarchingLayer/Assets.xcassets/sheet8.imageset/sheet8@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cemolcay/MarchingLayer/641c8ff861162b6313926cc3848ef28ee020445d/MarchingLayer/Assets.xcassets/sheet8.imageset/sheet8@2x.png -------------------------------------------------------------------------------- /MarchingLayer/Assets.xcassets/sheet8.imageset/sheet8@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cemolcay/MarchingLayer/641c8ff861162b6313926cc3848ef28ee020445d/MarchingLayer/Assets.xcassets/sheet8.imageset/sheet8@3x.png -------------------------------------------------------------------------------- /MarchingLayer/Assets.xcassets/sheet9.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "sheet9.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "sheet9@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "sheet9@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /MarchingLayer/Assets.xcassets/sheet9.imageset/sheet9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cemolcay/MarchingLayer/641c8ff861162b6313926cc3848ef28ee020445d/MarchingLayer/Assets.xcassets/sheet9.imageset/sheet9.png -------------------------------------------------------------------------------- /MarchingLayer/Assets.xcassets/sheet9.imageset/sheet9@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cemolcay/MarchingLayer/641c8ff861162b6313926cc3848ef28ee020445d/MarchingLayer/Assets.xcassets/sheet9.imageset/sheet9@2x.png -------------------------------------------------------------------------------- /MarchingLayer/Assets.xcassets/sheet9.imageset/sheet9@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cemolcay/MarchingLayer/641c8ff861162b6313926cc3848ef28ee020445d/MarchingLayer/Assets.xcassets/sheet9.imageset/sheet9@3x.png -------------------------------------------------------------------------------- /MarchingLayer/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /MarchingLayer/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 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /MarchingLayer/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 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /MarchingLayer/MarchingLayer.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MarchingLayer.swift 3 | // MarchingLayer 4 | // 5 | // Created by Cem Olcay on 12.11.2017. 6 | // Copyright © 2017 cemolcay. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | extension UIImage { 12 | 13 | /// Applies tint color to template rendered images. 14 | /// 15 | /// - Parameters: 16 | /// - tintColor: Color you want to apply. 17 | /// - size: Optional new size. Leave it nil if you want to use original image size. Defaults nil. 18 | /// - Returns: Returns tint colored version of the image. 19 | public func tintColoredImage(tintColor: UIColor?) -> UIImage? { 20 | guard let tintColor = tintColor else { return self } 21 | var tintedImage: UIImage? 22 | let image = withRenderingMode(.alwaysTemplate) 23 | UIGraphicsBeginImageContextWithOptions(size, false, scale) 24 | tintColor.set() 25 | image.draw(in: CGRect(origin: .zero, size: size)) 26 | tintedImage = UIGraphicsGetImageFromCurrentImageContext() 27 | UIGraphicsEndImageContext() 28 | return tintedImage ?? self 29 | } 30 | } 31 | 32 | /// `MarchingLayer` animation direction. 33 | public enum MarchingLayerAnimationDirection { 34 | /// Animates sprites from bottom of the layer to top of the layer. 35 | case up 36 | /// Animates sprites from top of the layer to down of the layer. 37 | case down 38 | /// Animates sprites from right of the layer to left of the layer. 39 | case left 40 | /// Animates sprites from left of the layer to right of the layer. 41 | case right 42 | } 43 | 44 | /// Sprite item of `MarchingLayer`. 45 | public class MarchingSpriteLayer: CALayer { 46 | /// Image of the sprite layer renders. 47 | var sprite: UIImage? 48 | /// Size of the sprite. 49 | var size: CGSize 50 | 51 | /// Initilize with a sprite image and optional preferred sprite size. 52 | /// 53 | /// - Parameters: 54 | /// - sprite: Image reference of sprite. 55 | /// - preferredSize: Optional preferred size for sprite. Defaults nil. Leave nil for using original image size. 56 | init(sprite: UIImage, preferredSize: CGSize? = nil) { 57 | self.size = preferredSize ?? sprite.size 58 | self.sprite = sprite 59 | super.init() 60 | // Setup sprite 61 | frame = CGRect(origin: .zero, size: self.size) 62 | contentsGravity = kCAGravityResizeAspect 63 | contentsScale = UIScreen.main.scale 64 | contents = sprite.cgImage 65 | } 66 | 67 | public override init(layer: Any) { 68 | self.size = .zero 69 | super.init(layer: layer) 70 | } 71 | 72 | public required init?(coder aDecoder: NSCoder) { 73 | self.size = .zero 74 | super.init(coder: aDecoder) 75 | } 76 | } 77 | 78 | /// Randomly fills layer with sprites and move them in any direction and speed you want. 79 | public class MarchingLayer: CALayer { 80 | /// Marching sprites. Layer randomly pops images from this array. 81 | public var sprites = [UIImage]() 82 | /// Direction of the marching animation. 83 | public var animationDirection = MarchingLayerAnimationDirection.up 84 | /// Speed of the marching animation. 85 | public var animationSpeed: CGFloat = 0.1 86 | /// Horizontal spacing between sprites. 87 | public var horizontalSpriteSpacing: CGFloat = 10.0 88 | /// Vertical spacing between sprites. 89 | public var verticalSpriteSpacing: CGFloat = 10.0 90 | /// Set if you want to make all sprites size equal. 91 | /// Leave it nil if you want to use original sprite sizes. Defaults nil. 92 | public var preferredSpriteSize: CGSize? 93 | /// Set if you want to make all sprites same tint color. Leave it nil if you want to use original images. 94 | /// Setup images as template images if you want to use that feature. Defaults nil. 95 | public var preferredSpriteTintColor: UIColor? 96 | /// Read-only property to check if layer is animating. 97 | public private(set) var isAnimating = false 98 | /// All sprite sublayers in layer. 99 | private var marchingSprites = [MarchingSpriteLayer]() 100 | /// Timer makes marching animation. 101 | private var marchingAnimationTimer: Timer? 102 | 103 | /// Returns a random image from `sprites` array. Returns nil if array is empty. 104 | private var randomImage: UIImage? { 105 | if sprites.count <= 0 { 106 | return nil 107 | } 108 | let index = Int(arc4random_uniform(UInt32(sprites.count))) 109 | return sprites[index].tintColoredImage(tintColor: preferredSpriteTintColor) 110 | } 111 | 112 | // MARK: Lifecycle 113 | 114 | deinit { 115 | stopAnimation() 116 | marchingSprites.forEach({ $0.removeFromSuperlayer() }) 117 | } 118 | 119 | // MARK: Drawing 120 | 121 | public override var frame: CGRect { 122 | didSet { 123 | redraw() 124 | } 125 | } 126 | 127 | public override func layoutSublayers() { 128 | super.layoutSublayers() 129 | if marchingSprites.isEmpty { 130 | setupSprites() 131 | } 132 | } 133 | 134 | /// Redraws layer from top. 135 | public func redraw() { 136 | let animating = isAnimating 137 | stopAnimation() 138 | marchingSprites.forEach({ $0.removeFromSuperlayer() }) 139 | marchingSprites = [] 140 | layoutIfNeeded() 141 | if animating { 142 | startAnimation() 143 | } 144 | } 145 | 146 | 147 | /// Pops the initial sprites into empty layer. 148 | private func setupSprites() { 149 | // Reset sublayers 150 | marchingSprites.forEach({ $0.removeFromSuperlayer() }) 151 | marchingSprites = [] 152 | 153 | var currentX: CGFloat = 0 154 | var currentY: CGFloat = 0 155 | var maxY: CGFloat = 0 156 | while currentY < frame.size.height { 157 | guard let randomImage = randomImage else { continue } 158 | let randomSprite = MarchingSpriteLayer( 159 | sprite: randomImage, 160 | preferredSize: preferredSpriteSize) 161 | marchingSprites.append(randomSprite) 162 | addSublayer(randomSprite) 163 | 164 | // Layout sprite. 165 | randomSprite.frame.origin = CGPoint(x: currentX, y: currentY) 166 | currentX += randomSprite.size.width + horizontalSpriteSpacing 167 | maxY = max(maxY, randomSprite.size.height) 168 | 169 | // Move to new row. 170 | if currentX > frame.size.width { 171 | currentX = 0 172 | currentY += maxY + verticalSpriteSpacing 173 | maxY = 0 174 | } 175 | } 176 | } 177 | 178 | // MARK: Animating 179 | 180 | /// Starts the marching animation. 181 | public func startAnimation() { 182 | isAnimating = true 183 | marchingAnimationTimer = Timer.scheduledTimer( 184 | timeInterval: 1.0/60.0, // 60 FPS 185 | target: self, 186 | selector: #selector(marchingAnimation), 187 | userInfo: nil, 188 | repeats: true) 189 | } 190 | 191 | /// Stops the marching animation. 192 | public func stopAnimation() { 193 | isAnimating = false 194 | marchingAnimationTimer?.invalidate() 195 | marchingAnimationTimer = nil 196 | } 197 | 198 | /// Marhing animation tick. 199 | @objc private func marchingAnimation() { 200 | var removingSprites = [MarchingSpriteLayer]() 201 | for sprite in marchingSprites { 202 | var shouldRemove = false 203 | switch animationDirection { 204 | case .up: 205 | sprite.frame.origin.y -= animationSpeed 206 | shouldRemove = sprite.frame.origin.y + (sprite.frame.height / 2) < 0 207 | case .down: 208 | sprite.frame.origin.y += animationSpeed 209 | shouldRemove = sprite.frame.origin.y + (sprite.frame.size.height / 2) > frame.size.height 210 | case .left: 211 | sprite.frame.origin.x -= animationSpeed 212 | shouldRemove = sprite.frame.origin.x + sprite.frame.size.width < 0 213 | case .right: 214 | sprite.frame.origin.x += animationSpeed 215 | shouldRemove = sprite.frame.origin.x > frame.size.width 216 | } 217 | 218 | if shouldRemove { 219 | removingSprites.append(sprite) 220 | } 221 | } 222 | 223 | for sprite in removingSprites { 224 | guard let index = marchingSprites.index(of: sprite), 225 | let randomImage = randomImage 226 | else { continue } 227 | 228 | CATransaction.begin() 229 | CATransaction.setValue(kCFBooleanTrue, forKey: kCATransactionDisableActions) 230 | 231 | // Spawn new sprite 232 | let randomSprite = MarchingSpriteLayer( 233 | sprite: randomImage, 234 | preferredSize: preferredSpriteSize) 235 | marchingSprites.append(randomSprite) 236 | addSublayer(randomSprite) 237 | 238 | // Layout sprite 239 | switch animationDirection { 240 | case .up: 241 | randomSprite.position.x = marchingSprites[index].position.x 242 | randomSprite.frame.origin.y = frame.size.height + verticalSpriteSpacing 243 | case .down: 244 | randomSprite.position.x = marchingSprites[index].position.x 245 | randomSprite.frame.origin.y = verticalSpriteSpacing 246 | case .left: 247 | randomSprite.position.y = marchingSprites[index].position.y 248 | randomSprite.frame.origin.x = frame.size.width + horizontalSpriteSpacing 249 | case .right: 250 | randomSprite.position.y = marchingSprites[index].position.y 251 | randomSprite.frame.origin.x = -horizontalSpriteSpacing 252 | } 253 | 254 | // Remove sprite 255 | marchingSprites.remove(at: index).removeFromSuperlayer() 256 | CATransaction.commit() 257 | } 258 | 259 | removingSprites.removeAll() 260 | } 261 | } 262 | -------------------------------------------------------------------------------- /MarchingLayer/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // MarchingLayer 4 | // 5 | // Created by Cem Olcay on 12.11.2017. 6 | // Copyright © 2017 cemolcay. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ViewController: UIViewController { 12 | @IBOutlet weak var marchingLayerReferanceView: UIView? 13 | let marchingLayer = MarchingLayer() 14 | 15 | override func viewDidLoad() { 16 | super.viewDidLoad() 17 | marchingLayerReferanceView?.layer.addSublayer(marchingLayer) 18 | marchingLayer.frame = marchingLayerReferanceView?.frame ?? .zero 19 | marchingLayer.animationDirection = .right 20 | marchingLayer.animationSpeed = 1 21 | marchingLayer.preferredSpriteSize = CGSize(width: 50, height: 50) 22 | marchingLayer.verticalSpriteSpacing = 8 23 | marchingLayer.horizontalSpriteSpacing = 8 24 | marchingLayer.preferredSpriteTintColor = .darkGray 25 | marchingLayer.sprites = [Int](1...15).flatMap({ UIImage(named: "sheet\($0)") }) 26 | marchingLayer.startAnimation() 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | MarchingLayer 2 | ==== 3 | 4 | Randomly fills layer with sprites and move them in any direction and speed you want. 5 | 6 | Demo 7 | ---- 8 | 9 | ![alt tag](https://github.com/cemolcay/MarchingLayer/raw/master/demo.gif) 10 | 11 | Requirements 12 | ---- 13 | 14 | * Swift 4.0+ 15 | * iOS 8.0+ 16 | * tvOS 9.0+ 17 | 18 | Install 19 | ---- 20 | 21 | ``` 22 | pod 'MarchingLayer' 23 | ``` 24 | 25 | Usage 26 | ---- 27 | 28 | Create and add a `MarchingLayer` into your view. 29 | Set `sprites` property with images you want to show in layer. 30 | Set `animationDirection` to `up`, `down`, `left` or `right`. 31 | Set `animationSpeed` to change animation speed. 32 | Call `startAnimation()` to start, `stopAnimation()` to stop marching animation. -------------------------------------------------------------------------------- /demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cemolcay/MarchingLayer/641c8ff861162b6313926cc3848ef28ee020445d/demo.gif --------------------------------------------------------------------------------