├── .gitignore ├── Example ├── AppDelegate.swift ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ └── LaunchScreen.storyboard ├── DemoViewController.swift └── Info.plist ├── LICENSE ├── Loader.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── README.md ├── Source ├── Asset │ ├── Loader.gif │ └── Loader.png ├── Loader.swift └── Switch.swift └── SwitchLoader.podspec /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | build/ 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | xcuserdata 13 | *.xccheckout 14 | *.moved-aside 15 | DerivedData 16 | *.hmap 17 | *.ipa 18 | *.xcuserstate 19 | 20 | # CocoaPods 21 | # 22 | # We recommend against adding the Pods directory to your .gitignore. However 23 | # you should judge for yourself, the pros and cons are mentioned at: 24 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 25 | # 26 | # Pods/ 27 | 28 | # Carthage 29 | # 30 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 31 | # Carthage/Checkouts 32 | 33 | Carthage/Build 34 | -------------------------------------------------------------------------------- /Example/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // Loader 4 | // 5 | // Created by Lucas Ortis on 06/12/2015. 6 | // Copyright © 2015 Ekhoo. 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: [NSObject: AnyObject]?) -> Bool { 18 | self.window = UIWindow(frame: UIScreen.mainScreen().bounds) 19 | 20 | let rootViewController: DemoViewController = DemoViewController() 21 | self.window!.rootViewController = rootViewController 22 | 23 | self.window!.makeKeyAndVisible() 24 | 25 | return true 26 | } 27 | 28 | func applicationWillResignActive(application: UIApplication) { 29 | } 30 | 31 | func applicationDidEnterBackground(application: UIApplication) { 32 | } 33 | 34 | func applicationWillEnterForeground(application: UIApplication) { 35 | } 36 | 37 | func applicationDidBecomeActive(application: UIApplication) { 38 | } 39 | 40 | func applicationWillTerminate(application: UIApplication) { 41 | } 42 | 43 | 44 | } 45 | 46 | -------------------------------------------------------------------------------- /Example/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /Example/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 | -------------------------------------------------------------------------------- /Example/DemoViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DemoViewController.swift 3 | // Loader 4 | // 5 | // Created by Lucas Ortis on 06/12/2015. 6 | // Copyright © 2015 Ekhoo. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class DemoViewController: UIViewController { 12 | 13 | var loader: Loader! 14 | 15 | override func loadView() { 16 | super.loadView() 17 | 18 | self.view.backgroundColor = UIColor(red: 175.0 / 255.0, green: 85.0 / 255.0, blue: 255.0 / 255.0, alpha: 1.0) 19 | 20 | self.loader = Loader(frame: CGRectMake(0.0, 0.0, 80.0, 40.0)) 21 | loader.center = self.view.center 22 | 23 | self.view.addSubview(loader) 24 | } 25 | 26 | override func viewDidAppear(animated: Bool) { 27 | super.viewDidAppear(animated) 28 | 29 | self.loader.startAnimating() 30 | } 31 | 32 | override func prefersStatusBarHidden() -> Bool { 33 | return true 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Example/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Lucas Ortis 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 | 23 | -------------------------------------------------------------------------------- /Loader.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | BE57DF201C149DF40071595C /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE57DF181C149DF40071595C /* AppDelegate.swift */; }; 11 | BE57DF211C149DF40071595C /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = BE57DF191C149DF40071595C /* Assets.xcassets */; }; 12 | BE57DF221C149DF40071595C /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = BE57DF1A1C149DF40071595C /* LaunchScreen.storyboard */; }; 13 | BEE0F2861C149EDC00AFA2DE /* DemoViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BEE0F2851C149EDC00AFA2DE /* DemoViewController.swift */; }; 14 | BEE0F2881C149EFA00AFA2DE /* Loader.swift in Sources */ = {isa = PBXBuildFile; fileRef = BEE0F2871C149EFA00AFA2DE /* Loader.swift */; }; 15 | BEE0F28A1C14A6E800AFA2DE /* Switch.swift in Sources */ = {isa = PBXBuildFile; fileRef = BEE0F2891C14A6E800AFA2DE /* Switch.swift */; }; 16 | /* End PBXBuildFile section */ 17 | 18 | /* Begin PBXFileReference section */ 19 | BE3156741C149D0F00BA4E59 /* Loader.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Loader.app; sourceTree = BUILT_PRODUCTS_DIR; }; 20 | BE57DF181C149DF40071595C /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = AppDelegate.swift; path = Example/AppDelegate.swift; sourceTree = SOURCE_ROOT; }; 21 | BE57DF191C149DF40071595C /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Assets.xcassets; path = Example/Assets.xcassets; sourceTree = SOURCE_ROOT; }; 22 | BE57DF1B1C149DF40071595C /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Example/Base.lproj/LaunchScreen.storyboard; sourceTree = SOURCE_ROOT; }; 23 | BE57DF1E1C149DF40071595C /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = Example/Info.plist; sourceTree = SOURCE_ROOT; }; 24 | BEE0F2851C149EDC00AFA2DE /* DemoViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = DemoViewController.swift; path = Example/DemoViewController.swift; sourceTree = SOURCE_ROOT; }; 25 | BEE0F2871C149EFA00AFA2DE /* Loader.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Loader.swift; path = Source/Loader.swift; sourceTree = SOURCE_ROOT; }; 26 | BEE0F2891C14A6E800AFA2DE /* Switch.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Switch.swift; path = Source/Switch.swift; sourceTree = SOURCE_ROOT; }; 27 | /* End PBXFileReference section */ 28 | 29 | /* Begin PBXFrameworksBuildPhase section */ 30 | BE3156711C149D0F00BA4E59 /* Frameworks */ = { 31 | isa = PBXFrameworksBuildPhase; 32 | buildActionMask = 2147483647; 33 | files = ( 34 | ); 35 | runOnlyForDeploymentPostprocessing = 0; 36 | }; 37 | /* End PBXFrameworksBuildPhase section */ 38 | 39 | /* Begin PBXGroup section */ 40 | BE31566B1C149D0F00BA4E59 = { 41 | isa = PBXGroup; 42 | children = ( 43 | BE3156761C149D0F00BA4E59 /* Loader */, 44 | BE3156751C149D0F00BA4E59 /* Products */, 45 | ); 46 | sourceTree = ""; 47 | }; 48 | BE3156751C149D0F00BA4E59 /* Products */ = { 49 | isa = PBXGroup; 50 | children = ( 51 | BE3156741C149D0F00BA4E59 /* Loader.app */, 52 | ); 53 | name = Products; 54 | sourceTree = ""; 55 | }; 56 | BE3156761C149D0F00BA4E59 /* Loader */ = { 57 | isa = PBXGroup; 58 | children = ( 59 | BEE0F2821C149E8600AFA2DE /* Source */, 60 | BE57DF181C149DF40071595C /* AppDelegate.swift */, 61 | BE57DF191C149DF40071595C /* Assets.xcassets */, 62 | BE57DF1A1C149DF40071595C /* LaunchScreen.storyboard */, 63 | BE57DF1E1C149DF40071595C /* Info.plist */, 64 | BEE0F2851C149EDC00AFA2DE /* DemoViewController.swift */, 65 | ); 66 | path = Loader; 67 | sourceTree = ""; 68 | }; 69 | BEE0F2821C149E8600AFA2DE /* Source */ = { 70 | isa = PBXGroup; 71 | children = ( 72 | BEE0F2871C149EFA00AFA2DE /* Loader.swift */, 73 | BEE0F2891C14A6E800AFA2DE /* Switch.swift */, 74 | ); 75 | name = Source; 76 | sourceTree = ""; 77 | }; 78 | /* End PBXGroup section */ 79 | 80 | /* Begin PBXNativeTarget section */ 81 | BE3156731C149D0F00BA4E59 /* Loader */ = { 82 | isa = PBXNativeTarget; 83 | buildConfigurationList = BE3156861C149D0F00BA4E59 /* Build configuration list for PBXNativeTarget "Loader" */; 84 | buildPhases = ( 85 | BE3156701C149D0F00BA4E59 /* Sources */, 86 | BE3156711C149D0F00BA4E59 /* Frameworks */, 87 | BE3156721C149D0F00BA4E59 /* Resources */, 88 | ); 89 | buildRules = ( 90 | ); 91 | dependencies = ( 92 | ); 93 | name = Loader; 94 | productName = Loader; 95 | productReference = BE3156741C149D0F00BA4E59 /* Loader.app */; 96 | productType = "com.apple.product-type.application"; 97 | }; 98 | /* End PBXNativeTarget section */ 99 | 100 | /* Begin PBXProject section */ 101 | BE31566C1C149D0F00BA4E59 /* Project object */ = { 102 | isa = PBXProject; 103 | attributes = { 104 | LastSwiftUpdateCheck = 0710; 105 | LastUpgradeCheck = 0710; 106 | ORGANIZATIONNAME = Ekhoo; 107 | TargetAttributes = { 108 | BE3156731C149D0F00BA4E59 = { 109 | CreatedOnToolsVersion = 7.1; 110 | }; 111 | }; 112 | }; 113 | buildConfigurationList = BE31566F1C149D0F00BA4E59 /* Build configuration list for PBXProject "Loader" */; 114 | compatibilityVersion = "Xcode 3.2"; 115 | developmentRegion = English; 116 | hasScannedForEncodings = 0; 117 | knownRegions = ( 118 | en, 119 | Base, 120 | ); 121 | mainGroup = BE31566B1C149D0F00BA4E59; 122 | productRefGroup = BE3156751C149D0F00BA4E59 /* Products */; 123 | projectDirPath = ""; 124 | projectRoot = ""; 125 | targets = ( 126 | BE3156731C149D0F00BA4E59 /* Loader */, 127 | ); 128 | }; 129 | /* End PBXProject section */ 130 | 131 | /* Begin PBXResourcesBuildPhase section */ 132 | BE3156721C149D0F00BA4E59 /* Resources */ = { 133 | isa = PBXResourcesBuildPhase; 134 | buildActionMask = 2147483647; 135 | files = ( 136 | BE57DF211C149DF40071595C /* Assets.xcassets in Resources */, 137 | BE57DF221C149DF40071595C /* LaunchScreen.storyboard in Resources */, 138 | ); 139 | runOnlyForDeploymentPostprocessing = 0; 140 | }; 141 | /* End PBXResourcesBuildPhase section */ 142 | 143 | /* Begin PBXSourcesBuildPhase section */ 144 | BE3156701C149D0F00BA4E59 /* Sources */ = { 145 | isa = PBXSourcesBuildPhase; 146 | buildActionMask = 2147483647; 147 | files = ( 148 | BE57DF201C149DF40071595C /* AppDelegate.swift in Sources */, 149 | BEE0F28A1C14A6E800AFA2DE /* Switch.swift in Sources */, 150 | BEE0F2861C149EDC00AFA2DE /* DemoViewController.swift in Sources */, 151 | BEE0F2881C149EFA00AFA2DE /* Loader.swift in Sources */, 152 | ); 153 | runOnlyForDeploymentPostprocessing = 0; 154 | }; 155 | /* End PBXSourcesBuildPhase section */ 156 | 157 | /* Begin PBXVariantGroup section */ 158 | BE57DF1A1C149DF40071595C /* LaunchScreen.storyboard */ = { 159 | isa = PBXVariantGroup; 160 | children = ( 161 | BE57DF1B1C149DF40071595C /* Base */, 162 | ); 163 | name = LaunchScreen.storyboard; 164 | sourceTree = ""; 165 | }; 166 | /* End PBXVariantGroup section */ 167 | 168 | /* Begin XCBuildConfiguration section */ 169 | BE3156841C149D0F00BA4E59 /* Debug */ = { 170 | isa = XCBuildConfiguration; 171 | buildSettings = { 172 | ALWAYS_SEARCH_USER_PATHS = NO; 173 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 174 | CLANG_CXX_LIBRARY = "libc++"; 175 | CLANG_ENABLE_MODULES = YES; 176 | CLANG_ENABLE_OBJC_ARC = YES; 177 | CLANG_WARN_BOOL_CONVERSION = YES; 178 | CLANG_WARN_CONSTANT_CONVERSION = YES; 179 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 180 | CLANG_WARN_EMPTY_BODY = YES; 181 | CLANG_WARN_ENUM_CONVERSION = YES; 182 | CLANG_WARN_INT_CONVERSION = YES; 183 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 184 | CLANG_WARN_UNREACHABLE_CODE = YES; 185 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 186 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 187 | COPY_PHASE_STRIP = NO; 188 | DEBUG_INFORMATION_FORMAT = dwarf; 189 | ENABLE_STRICT_OBJC_MSGSEND = YES; 190 | ENABLE_TESTABILITY = YES; 191 | GCC_C_LANGUAGE_STANDARD = gnu99; 192 | GCC_DYNAMIC_NO_PIC = NO; 193 | GCC_NO_COMMON_BLOCKS = YES; 194 | GCC_OPTIMIZATION_LEVEL = 0; 195 | GCC_PREPROCESSOR_DEFINITIONS = ( 196 | "DEBUG=1", 197 | "$(inherited)", 198 | ); 199 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 200 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 201 | GCC_WARN_UNDECLARED_SELECTOR = YES; 202 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 203 | GCC_WARN_UNUSED_FUNCTION = YES; 204 | GCC_WARN_UNUSED_VARIABLE = YES; 205 | IPHONEOS_DEPLOYMENT_TARGET = 9.1; 206 | MTL_ENABLE_DEBUG_INFO = YES; 207 | ONLY_ACTIVE_ARCH = YES; 208 | SDKROOT = iphoneos; 209 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 210 | }; 211 | name = Debug; 212 | }; 213 | BE3156851C149D0F00BA4E59 /* Release */ = { 214 | isa = XCBuildConfiguration; 215 | buildSettings = { 216 | ALWAYS_SEARCH_USER_PATHS = NO; 217 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 218 | CLANG_CXX_LIBRARY = "libc++"; 219 | CLANG_ENABLE_MODULES = YES; 220 | CLANG_ENABLE_OBJC_ARC = YES; 221 | CLANG_WARN_BOOL_CONVERSION = YES; 222 | CLANG_WARN_CONSTANT_CONVERSION = YES; 223 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 224 | CLANG_WARN_EMPTY_BODY = YES; 225 | CLANG_WARN_ENUM_CONVERSION = YES; 226 | CLANG_WARN_INT_CONVERSION = YES; 227 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 228 | CLANG_WARN_UNREACHABLE_CODE = YES; 229 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 230 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 231 | COPY_PHASE_STRIP = NO; 232 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 233 | ENABLE_NS_ASSERTIONS = NO; 234 | ENABLE_STRICT_OBJC_MSGSEND = YES; 235 | GCC_C_LANGUAGE_STANDARD = gnu99; 236 | GCC_NO_COMMON_BLOCKS = YES; 237 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 238 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 239 | GCC_WARN_UNDECLARED_SELECTOR = YES; 240 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 241 | GCC_WARN_UNUSED_FUNCTION = YES; 242 | GCC_WARN_UNUSED_VARIABLE = YES; 243 | IPHONEOS_DEPLOYMENT_TARGET = 9.1; 244 | MTL_ENABLE_DEBUG_INFO = NO; 245 | SDKROOT = iphoneos; 246 | VALIDATE_PRODUCT = YES; 247 | }; 248 | name = Release; 249 | }; 250 | BE3156871C149D0F00BA4E59 /* Debug */ = { 251 | isa = XCBuildConfiguration; 252 | buildSettings = { 253 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 254 | CLANG_ENABLE_MODULES = YES; 255 | INFOPLIST_FILE = "$(SRCROOT)/Example/Info.plist"; 256 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 257 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 258 | PRODUCT_BUNDLE_IDENTIFIER = Ekhoo.Loader; 259 | PRODUCT_NAME = "$(TARGET_NAME)"; 260 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 261 | }; 262 | name = Debug; 263 | }; 264 | BE3156881C149D0F00BA4E59 /* Release */ = { 265 | isa = XCBuildConfiguration; 266 | buildSettings = { 267 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 268 | CLANG_ENABLE_MODULES = YES; 269 | INFOPLIST_FILE = "$(SRCROOT)/Example/Info.plist"; 270 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 271 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 272 | PRODUCT_BUNDLE_IDENTIFIER = Ekhoo.Loader; 273 | PRODUCT_NAME = "$(TARGET_NAME)"; 274 | }; 275 | name = Release; 276 | }; 277 | /* End XCBuildConfiguration section */ 278 | 279 | /* Begin XCConfigurationList section */ 280 | BE31566F1C149D0F00BA4E59 /* Build configuration list for PBXProject "Loader" */ = { 281 | isa = XCConfigurationList; 282 | buildConfigurations = ( 283 | BE3156841C149D0F00BA4E59 /* Debug */, 284 | BE3156851C149D0F00BA4E59 /* Release */, 285 | ); 286 | defaultConfigurationIsVisible = 0; 287 | defaultConfigurationName = Release; 288 | }; 289 | BE3156861C149D0F00BA4E59 /* Build configuration list for PBXNativeTarget "Loader" */ = { 290 | isa = XCConfigurationList; 291 | buildConfigurations = ( 292 | BE3156871C149D0F00BA4E59 /* Debug */, 293 | BE3156881C149D0F00BA4E59 /* Release */, 294 | ); 295 | defaultConfigurationIsVisible = 0; 296 | defaultConfigurationName = Release; 297 | }; 298 | /* End XCConfigurationList section */ 299 | }; 300 | rootObject = BE31566C1C149D0F00BA4E59 /* Project object */; 301 | } 302 | -------------------------------------------------------------------------------- /Loader.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![Loader](https://github.com/Ekhoo/Loader/blob/master/Source/Asset/Loader.png) 2 | 3 | [![Version](https://img.shields.io/cocoapods/v/SwitchLoader.svg?style=flat)](http://cocoapods.org/pods/SwitchLoader) 4 | [![License](https://img.shields.io/cocoapods/l/SwitchLoader.svg?style=flat)](http://cocoapods.org/pods/SwitchLoader) 5 | [![Platform](https://img.shields.io/cocoapods/p/SwitchLoader.svg?style=flat)](http://cocoapods.org/pods/SwitchLoader) 6 | ![](https://img.shields.io/badge/Supported-iOS8-4BC51D.svg?style=flat-square) 7 | [![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) 8 | ![](https://img.shields.io/badge/Swift 2-compatible-4BC51D.svg?style=flat-square) 9 | 10 | Simple and light weight animated switch activity indicator. 11 | 12 | # Demo 13 | 14 | ![Loader](https://github.com/Ekhoo/Loader/blob/master/Source/Asset/Loader.gif) 15 | 16 | # Installation 17 | ## CocoaPods 18 | Loader is available through [CocoaPods](http://cocoapods.org). To install 19 | it, simply add the following line to your Podfile: 20 | 21 | ```ruby 22 | pod "SwitchLoader", '~> 0.0.1' 23 | ``` 24 | 25 | ## Carthage 26 | 27 | [Carthage](https://github.com/Carthage/Carthage) is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. 28 | 29 | You can install Carthage with [Homebrew](http://brew.sh/) using the following command: 30 | 31 | ```bash 32 | $ brew update 33 | $ brew install carthage 34 | ``` 35 | 36 | To integrate Loader into your Xcode project using Carthage, specify it in your `Cartfile`: 37 | 38 | ```ogdl 39 | github "Ekhoo/Loader" ~> 0.0.1 40 | ``` 41 | 42 | Run `carthage update` to build the framework and drag the built `Loader.framework` into your Xcode project. 43 | 44 | # Usage 45 | ```swift 46 | func myFunc() { 47 | let loader: Loader = Loader(frame: CGRectMake(0.0, 0.0, 80.0, 40.0)) 48 | 49 | self.view.addSubView(loader) 50 | 51 | loader.startAnimating() 52 | } 53 | ``` 54 | 55 | ## Interface 56 | ```swift 57 | public func startAnimating() // Animate the switch activity indicator 58 | public func stoptAnimating() // Stop Animating the switch activity indicator 59 | 60 | public var loaderColor: UIColor // The background color 61 | public var switchColor: UIColor // The animated switch color 62 | ``` 63 | 64 | # Author 65 | Lucas Ortis: 66 | - me@lucas-ortis.com 67 | - [@LucasEkhoo](https://twitter.com/LucasEkhoo) 68 | - [Linkedin](https://fr.linkedin.com/in/lucasortis) 69 | 70 | # License 71 | 72 | Inspired from this [Dribbble](https://dribbble.com/shots/2389529-Like-a-preloader) project. 73 | Loader is available under the MIT license. See the LICENSE file for more info. 74 | -------------------------------------------------------------------------------- /Source/Asset/Loader.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ekhoo/Loader/a2003fe747fa3f3a8fbac7f95d23d47eb01120cd/Source/Asset/Loader.gif -------------------------------------------------------------------------------- /Source/Asset/Loader.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ekhoo/Loader/a2003fe747fa3f3a8fbac7f95d23d47eb01120cd/Source/Asset/Loader.png -------------------------------------------------------------------------------- /Source/Loader.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Loader.swift 3 | // Loader 4 | // 5 | // Created by Lucas Ortis on 06/12/2015. 6 | // Copyright © 2015 Ekhoo. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | let kInset: CGFloat = 5.0 12 | 13 | public class Loader: UIView { 14 | 15 | private var switchView: UIView? 16 | private var switchAnimationSide: Bool = false 17 | private var animationTimer: NSTimer? 18 | 19 | var loaderColor: UIColor { 20 | didSet { 21 | self.setNeedsDisplay() 22 | } 23 | } 24 | var switchColor: UIColor { 25 | didSet { 26 | if let view = self.switchView { 27 | view.backgroundColor = self.switchColor 28 | } 29 | } 30 | } 31 | 32 | override init(frame: CGRect) { 33 | self.loaderColor = UIColor.whiteColor() 34 | self.switchColor = UIColor(red: 175.0 / 255.0, green: 85.0 / 255.0, blue: 255.0 / 255.0, alpha: 1.0) 35 | 36 | super.init(frame: frame) 37 | 38 | self.switchView = UIView(frame: CGRectMake(kInset, kInset, frame.size.height - 2 * kInset, frame.size.height - 2 * kInset)) 39 | self.switchView!.backgroundColor = self.switchColor 40 | self.switchView!.layer.cornerRadius = round(self.switchView!.frame.size.width / 2) 41 | self.switchView!.layer.masksToBounds = true 42 | 43 | self.backgroundColor = UIColor.clearColor() 44 | 45 | self.addSubview(self.switchView!) 46 | } 47 | 48 | required public init?(coder aDecoder: NSCoder) { 49 | fatalError("init(coder:) has not been implemented") 50 | } 51 | 52 | private func animateSwitch() { 53 | if (self.frame.width > self.frame.height) { 54 | return; 55 | } 56 | 57 | UIView.animateWithDuration(0.3, delay: 0.0, options: UIViewAnimationOptions.AllowAnimatedContent, animations: { () -> Void in 58 | let frame: CGRect = self.bounds 59 | 60 | if self.switchView!.frame.origin.x > kInset { 61 | self.switchView!.frame = CGRectMake(kInset, self.switchView!.frame.origin.y, frame.width - 2 * kInset, self.switchView!.frame.height) 62 | } else { 63 | self.switchView!.frame = CGRectMake(self.switchView!.frame.origin.x, self.switchView!.frame.origin.y, frame.width - 2 * kInset, self.switchView!.frame.height) 64 | } 65 | 66 | self.switchView!.setNeedsDisplay() 67 | }) { (finished) -> Void in 68 | UIView.animateWithDuration(0.30, animations: { () -> Void in 69 | let frame: CGRect = self.bounds 70 | 71 | if self.switchAnimationSide { 72 | self.switchView!.frame = CGRectMake(kInset, self.switchView!.frame.origin.y, self.switchView!.frame.size.height, self.switchView!.frame.height) 73 | } else { 74 | self.switchView!.frame = CGRectMake(frame.size.width - self.switchView!.frame.height - kInset, self.switchView!.frame.origin.y, self.switchView!.frame.size.height, self.switchView!.frame.height) 75 | } 76 | 77 | self.switchAnimationSide = !self.switchAnimationSide 78 | 79 | self.switchView!.setNeedsDisplay() 80 | }) 81 | } 82 | } 83 | 84 | @objc private func animateLoader() { 85 | UIView.animateWithDuration(0.4) { () -> Void in 86 | self.transform = CGAffineTransformRotate(self.transform, CGFloat(M_PI_2)); 87 | } 88 | 89 | animateSwitch() 90 | } 91 | 92 | public func startAnimating() { 93 | self.animationTimer = NSTimer.scheduledTimerWithTimeInterval(0.4, target: self, selector: "animateLoader", userInfo: nil, repeats: true) 94 | } 95 | 96 | public func stopAnimating() { 97 | if let timer = self.animationTimer { 98 | timer.invalidate() 99 | 100 | self.animationTimer = nil 101 | } 102 | } 103 | 104 | override public func drawRect(rect: CGRect) { 105 | let rectanglePath = UIBezierPath(roundedRect: CGRectMake(0.0, 0.0, rect.size.width, rect.size.height), cornerRadius: round(rect.size.width / 2.0)) 106 | self.loaderColor.setFill() 107 | rectanglePath.fill() 108 | } 109 | 110 | } 111 | -------------------------------------------------------------------------------- /Source/Switch.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Switch.swift 3 | // Loader 4 | // 5 | // Created by Lucas Ortis on 06/12/2015. 6 | // Copyright © 2015 Ekhoo. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class Switch: UIView { 12 | var switchColor: UIColor = UIColor(red: 255.0 / 255.0, green: 45.0 / 255.0, blue: 42.0 / 255.0, alpha: 1.0) 13 | 14 | override init(frame: CGRect) { 15 | super.init(frame: frame) 16 | 17 | self.backgroundColor = UIColor.clearColor() 18 | } 19 | 20 | required init?(coder aDecoder: NSCoder) { 21 | fatalError("init(coder:) has not been implemented") 22 | } 23 | 24 | override func drawRect(rect: CGRect) { 25 | let rectanglePath = UIBezierPath(roundedRect: CGRectMake(0.0, 0.0, rect.size.width, rect.size.height), cornerRadius: rect.size.width / 2.0) 26 | self.switchColor.setFill() 27 | rectanglePath.fill() 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /SwitchLoader.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "SwitchLoader" 3 | s.version = "0.0.1" 4 | s.summary = "Amazing animated switch activity indicator written in swift" 5 | 6 | s.description = "Simple and light weight animated switch activity indicator." 7 | 8 | s.homepage = "https://github.com/Ekhoo/Loader" 9 | s.license = { :type => "MIT", :file => "LICENSE" } 10 | s.author = { "Lucas Ortis" => "me@lucas-ortis.com" } 11 | s.platform = :ios, "8.0" 12 | s.source = { :git => "https://github.com/Ekhoo/Loader.git", :tag => s.version.to_s } 13 | s.source_files = "Source/*.swift" 14 | s.requires_arc = true 15 | end 16 | 17 | --------------------------------------------------------------------------------