├── .DS_Store ├── .gitignore ├── .swiftlint.yml ├── LICENSE ├── README.md ├── SlideTo.xcodeproj ├── project.pbxproj └── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ └── IDEWorkspaceChecks.plist └── SlideTo ├── AppDelegate.swift ├── Assets.xcassets └── AppIcon.appiconset │ └── Contents.json ├── Base.lproj ├── LaunchScreen.storyboard └── Main.storyboard ├── Info.plist ├── SlideToControl.swift ├── SlideToControl.xib └── ViewController.swift /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChristianMoler/SlideTo/314857ec3a56fd2fdc3f1328be1616d4e808e4ab/.DS_Store -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata/ 19 | 20 | ## Other 21 | *.moved-aside 22 | *.xccheckout 23 | *.xcscmblueprint 24 | 25 | ## Obj-C/Swift specific 26 | *.hmap 27 | *.ipa 28 | *.dSYM.zip 29 | *.dSYM 30 | 31 | ## Playgrounds 32 | timeline.xctimeline 33 | playground.xcworkspace 34 | 35 | # Swift Package Manager 36 | # 37 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 38 | # Packages/ 39 | # Package.pins 40 | .build/ 41 | 42 | # CocoaPods 43 | # 44 | # We recommend against adding the Pods directory to your .gitignore. However 45 | # you should judge for yourself, the pros and cons are mentioned at: 46 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 47 | # 48 | Pods/ 49 | 50 | # Carthage 51 | # 52 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 53 | # Carthage/Checkouts 54 | 55 | Carthage/Build 56 | 57 | # fastlane 58 | # 59 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 60 | # screenshots whenever they are needed. 61 | # For more information about the recommended setup visit: 62 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 63 | 64 | fastlane/report.xml 65 | fastlane/Preview.html 66 | fastlane/screenshots 67 | fastlane/test_output 68 | -------------------------------------------------------------------------------- /.swiftlint.yml: -------------------------------------------------------------------------------- 1 | disabled_rules: 2 | - file_length 3 | - force_cast 4 | - force_try 5 | - function_body_length 6 | - todo 7 | - type_body_length 8 | - line_length 9 | - vertical_whitespace 10 | - syntactic_sugar 11 | 12 | warning_threshold: 15 13 | line_length: 100 14 | 15 | 16 | variable_name: 17 | max_length: 18 | warning: 45 19 | error: 60 20 | min_length: 21 | warning: 0 22 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Christian 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Slide to control 2 | Simple slide controller is fully customizable via interface builder. 3 | ## Installing 4 | 5 | Just clone or download SlideToControl.swift and SlideToControl.xib files 6 | 7 | ## Getting Started 8 | 9 | 1. Add a view to the storyboard 10 | 2. Set constraints 11 | 3. Configurate using IB 12 | 4. Implement the protocol SlideToControlDelegate 13 | 14 | ### Example 15 | ![alt text](https://image.ibb.co/hH4zPQ/2017_09_18_23_48_12.png) 16 | ![alt text](https://image.ibb.co/fkCQyk/2017_09_18_23_43_39.png) 17 | 18 | ## License 19 | 20 | This project is licensed under the MIT License - see the [LICENSE.md](https://github.com/ChristianMoler/SlideTo/blob/master/LICENSE) file for details 21 | 22 | 23 | -------------------------------------------------------------------------------- /SlideTo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 48; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | F42B79101F6C0B85007D3CDD /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = F42B790F1F6C0B85007D3CDD /* AppDelegate.swift */; }; 11 | F42B79121F6C0B85007D3CDD /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F42B79111F6C0B85007D3CDD /* ViewController.swift */; }; 12 | F42B79151F6C0B85007D3CDD /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F42B79131F6C0B85007D3CDD /* Main.storyboard */; }; 13 | F42B79171F6C0B85007D3CDD /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = F42B79161F6C0B85007D3CDD /* Assets.xcassets */; }; 14 | F42B791A1F6C0B85007D3CDD /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F42B79181F6C0B85007D3CDD /* LaunchScreen.storyboard */; }; 15 | F42B79221F6C0C34007D3CDD /* SlideToControl.swift in Sources */ = {isa = PBXBuildFile; fileRef = F42B79211F6C0C34007D3CDD /* SlideToControl.swift */; }; 16 | F42B79241F6C0C55007D3CDD /* SlideToControl.xib in Resources */ = {isa = PBXBuildFile; fileRef = F42B79231F6C0C55007D3CDD /* SlideToControl.xib */; }; 17 | /* End PBXBuildFile section */ 18 | 19 | /* Begin PBXFileReference section */ 20 | F42B790C1F6C0B85007D3CDD /* SlideTo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SlideTo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 21 | F42B790F1F6C0B85007D3CDD /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 22 | F42B79111F6C0B85007D3CDD /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 23 | F42B79141F6C0B85007D3CDD /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 24 | F42B79161F6C0B85007D3CDD /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 25 | F42B79191F6C0B85007D3CDD /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 26 | F42B791B1F6C0B85007D3CDD /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 27 | F42B79211F6C0C34007D3CDD /* SlideToControl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SlideToControl.swift; sourceTree = ""; }; 28 | F42B79231F6C0C55007D3CDD /* SlideToControl.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = SlideToControl.xib; sourceTree = ""; }; 29 | /* End PBXFileReference section */ 30 | 31 | /* Begin PBXFrameworksBuildPhase section */ 32 | F42B79091F6C0B85007D3CDD /* Frameworks */ = { 33 | isa = PBXFrameworksBuildPhase; 34 | buildActionMask = 2147483647; 35 | files = ( 36 | ); 37 | runOnlyForDeploymentPostprocessing = 0; 38 | }; 39 | /* End PBXFrameworksBuildPhase section */ 40 | 41 | /* Begin PBXGroup section */ 42 | F42B79031F6C0B85007D3CDD = { 43 | isa = PBXGroup; 44 | children = ( 45 | F42B790E1F6C0B85007D3CDD /* SlideTo */, 46 | F42B790D1F6C0B85007D3CDD /* Products */, 47 | ); 48 | sourceTree = ""; 49 | }; 50 | F42B790D1F6C0B85007D3CDD /* Products */ = { 51 | isa = PBXGroup; 52 | children = ( 53 | F42B790C1F6C0B85007D3CDD /* SlideTo.app */, 54 | ); 55 | name = Products; 56 | sourceTree = ""; 57 | }; 58 | F42B790E1F6C0B85007D3CDD /* SlideTo */ = { 59 | isa = PBXGroup; 60 | children = ( 61 | F42B790F1F6C0B85007D3CDD /* AppDelegate.swift */, 62 | F42B79111F6C0B85007D3CDD /* ViewController.swift */, 63 | F42B79211F6C0C34007D3CDD /* SlideToControl.swift */, 64 | F42B79131F6C0B85007D3CDD /* Main.storyboard */, 65 | F42B79231F6C0C55007D3CDD /* SlideToControl.xib */, 66 | F42B79161F6C0B85007D3CDD /* Assets.xcassets */, 67 | F42B79181F6C0B85007D3CDD /* LaunchScreen.storyboard */, 68 | F42B791B1F6C0B85007D3CDD /* Info.plist */, 69 | ); 70 | path = SlideTo; 71 | sourceTree = ""; 72 | }; 73 | /* End PBXGroup section */ 74 | 75 | /* Begin PBXNativeTarget section */ 76 | F42B790B1F6C0B85007D3CDD /* SlideTo */ = { 77 | isa = PBXNativeTarget; 78 | buildConfigurationList = F42B791E1F6C0B85007D3CDD /* Build configuration list for PBXNativeTarget "SlideTo" */; 79 | buildPhases = ( 80 | F4272B272072CFE000FD80E6 /* ShellScript */, 81 | F42B79081F6C0B85007D3CDD /* Sources */, 82 | F42B79091F6C0B85007D3CDD /* Frameworks */, 83 | F42B790A1F6C0B85007D3CDD /* Resources */, 84 | ); 85 | buildRules = ( 86 | ); 87 | dependencies = ( 88 | ); 89 | name = SlideTo; 90 | productName = SlideTo; 91 | productReference = F42B790C1F6C0B85007D3CDD /* SlideTo.app */; 92 | productType = "com.apple.product-type.application"; 93 | }; 94 | /* End PBXNativeTarget section */ 95 | 96 | /* Begin PBXProject section */ 97 | F42B79041F6C0B85007D3CDD /* Project object */ = { 98 | isa = PBXProject; 99 | attributes = { 100 | LastSwiftUpdateCheck = 0900; 101 | LastUpgradeCheck = 0930; 102 | ORGANIZATIONNAME = "Christian Moler"; 103 | TargetAttributes = { 104 | F42B790B1F6C0B85007D3CDD = { 105 | CreatedOnToolsVersion = 9.0; 106 | ProvisioningStyle = Automatic; 107 | }; 108 | }; 109 | }; 110 | buildConfigurationList = F42B79071F6C0B85007D3CDD /* Build configuration list for PBXProject "SlideTo" */; 111 | compatibilityVersion = "Xcode 8.0"; 112 | developmentRegion = en; 113 | hasScannedForEncodings = 0; 114 | knownRegions = ( 115 | en, 116 | Base, 117 | ); 118 | mainGroup = F42B79031F6C0B85007D3CDD; 119 | productRefGroup = F42B790D1F6C0B85007D3CDD /* Products */; 120 | projectDirPath = ""; 121 | projectRoot = ""; 122 | targets = ( 123 | F42B790B1F6C0B85007D3CDD /* SlideTo */, 124 | ); 125 | }; 126 | /* End PBXProject section */ 127 | 128 | /* Begin PBXResourcesBuildPhase section */ 129 | F42B790A1F6C0B85007D3CDD /* Resources */ = { 130 | isa = PBXResourcesBuildPhase; 131 | buildActionMask = 2147483647; 132 | files = ( 133 | F42B79241F6C0C55007D3CDD /* SlideToControl.xib in Resources */, 134 | F42B791A1F6C0B85007D3CDD /* LaunchScreen.storyboard in Resources */, 135 | F42B79171F6C0B85007D3CDD /* Assets.xcassets in Resources */, 136 | F42B79151F6C0B85007D3CDD /* Main.storyboard in Resources */, 137 | ); 138 | runOnlyForDeploymentPostprocessing = 0; 139 | }; 140 | /* End PBXResourcesBuildPhase section */ 141 | 142 | /* Begin PBXShellScriptBuildPhase section */ 143 | F4272B272072CFE000FD80E6 /* ShellScript */ = { 144 | isa = PBXShellScriptBuildPhase; 145 | buildActionMask = 2147483647; 146 | files = ( 147 | ); 148 | inputPaths = ( 149 | ); 150 | outputPaths = ( 151 | ); 152 | runOnlyForDeploymentPostprocessing = 0; 153 | shellPath = /bin/sh; 154 | shellScript = "if which swiftlint >/dev/null; then\nswiftlint\nelse\necho \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi"; 155 | }; 156 | /* End PBXShellScriptBuildPhase section */ 157 | 158 | /* Begin PBXSourcesBuildPhase section */ 159 | F42B79081F6C0B85007D3CDD /* Sources */ = { 160 | isa = PBXSourcesBuildPhase; 161 | buildActionMask = 2147483647; 162 | files = ( 163 | F42B79121F6C0B85007D3CDD /* ViewController.swift in Sources */, 164 | F42B79221F6C0C34007D3CDD /* SlideToControl.swift in Sources */, 165 | F42B79101F6C0B85007D3CDD /* AppDelegate.swift in Sources */, 166 | ); 167 | runOnlyForDeploymentPostprocessing = 0; 168 | }; 169 | /* End PBXSourcesBuildPhase section */ 170 | 171 | /* Begin PBXVariantGroup section */ 172 | F42B79131F6C0B85007D3CDD /* Main.storyboard */ = { 173 | isa = PBXVariantGroup; 174 | children = ( 175 | F42B79141F6C0B85007D3CDD /* Base */, 176 | ); 177 | name = Main.storyboard; 178 | sourceTree = ""; 179 | }; 180 | F42B79181F6C0B85007D3CDD /* LaunchScreen.storyboard */ = { 181 | isa = PBXVariantGroup; 182 | children = ( 183 | F42B79191F6C0B85007D3CDD /* Base */, 184 | ); 185 | name = LaunchScreen.storyboard; 186 | sourceTree = ""; 187 | }; 188 | /* End PBXVariantGroup section */ 189 | 190 | /* Begin XCBuildConfiguration section */ 191 | F42B791C1F6C0B85007D3CDD /* Debug */ = { 192 | isa = XCBuildConfiguration; 193 | buildSettings = { 194 | ALWAYS_SEARCH_USER_PATHS = NO; 195 | CLANG_ANALYZER_NONNULL = YES; 196 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 197 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 198 | CLANG_CXX_LIBRARY = "libc++"; 199 | CLANG_ENABLE_MODULES = YES; 200 | CLANG_ENABLE_OBJC_ARC = YES; 201 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 202 | CLANG_WARN_BOOL_CONVERSION = YES; 203 | CLANG_WARN_COMMA = YES; 204 | CLANG_WARN_CONSTANT_CONVERSION = YES; 205 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 206 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 207 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 208 | CLANG_WARN_EMPTY_BODY = YES; 209 | CLANG_WARN_ENUM_CONVERSION = YES; 210 | CLANG_WARN_INFINITE_RECURSION = YES; 211 | CLANG_WARN_INT_CONVERSION = YES; 212 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 213 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 214 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 215 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 216 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 217 | CLANG_WARN_STRICT_PROTOTYPES = YES; 218 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 219 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 220 | CLANG_WARN_UNREACHABLE_CODE = YES; 221 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 222 | CODE_SIGN_IDENTITY = "iPhone Developer"; 223 | COPY_PHASE_STRIP = NO; 224 | DEBUG_INFORMATION_FORMAT = dwarf; 225 | ENABLE_STRICT_OBJC_MSGSEND = YES; 226 | ENABLE_TESTABILITY = YES; 227 | GCC_C_LANGUAGE_STANDARD = gnu11; 228 | GCC_DYNAMIC_NO_PIC = NO; 229 | GCC_NO_COMMON_BLOCKS = YES; 230 | GCC_OPTIMIZATION_LEVEL = 0; 231 | GCC_PREPROCESSOR_DEFINITIONS = ( 232 | "DEBUG=1", 233 | "$(inherited)", 234 | ); 235 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 236 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 237 | GCC_WARN_UNDECLARED_SELECTOR = YES; 238 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 239 | GCC_WARN_UNUSED_FUNCTION = YES; 240 | GCC_WARN_UNUSED_VARIABLE = YES; 241 | IPHONEOS_DEPLOYMENT_TARGET = 11.0; 242 | MTL_ENABLE_DEBUG_INFO = YES; 243 | ONLY_ACTIVE_ARCH = YES; 244 | SDKROOT = iphoneos; 245 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 246 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 247 | }; 248 | name = Debug; 249 | }; 250 | F42B791D1F6C0B85007D3CDD /* Release */ = { 251 | isa = XCBuildConfiguration; 252 | buildSettings = { 253 | ALWAYS_SEARCH_USER_PATHS = NO; 254 | CLANG_ANALYZER_NONNULL = YES; 255 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 256 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 257 | CLANG_CXX_LIBRARY = "libc++"; 258 | CLANG_ENABLE_MODULES = YES; 259 | CLANG_ENABLE_OBJC_ARC = YES; 260 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 261 | CLANG_WARN_BOOL_CONVERSION = YES; 262 | CLANG_WARN_COMMA = YES; 263 | CLANG_WARN_CONSTANT_CONVERSION = YES; 264 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 265 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 266 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 267 | CLANG_WARN_EMPTY_BODY = YES; 268 | CLANG_WARN_ENUM_CONVERSION = YES; 269 | CLANG_WARN_INFINITE_RECURSION = YES; 270 | CLANG_WARN_INT_CONVERSION = YES; 271 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 272 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 273 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 274 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 275 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 276 | CLANG_WARN_STRICT_PROTOTYPES = YES; 277 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 278 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 279 | CLANG_WARN_UNREACHABLE_CODE = YES; 280 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 281 | CODE_SIGN_IDENTITY = "iPhone Developer"; 282 | COPY_PHASE_STRIP = NO; 283 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 284 | ENABLE_NS_ASSERTIONS = NO; 285 | ENABLE_STRICT_OBJC_MSGSEND = YES; 286 | GCC_C_LANGUAGE_STANDARD = gnu11; 287 | GCC_NO_COMMON_BLOCKS = YES; 288 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 289 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 290 | GCC_WARN_UNDECLARED_SELECTOR = YES; 291 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 292 | GCC_WARN_UNUSED_FUNCTION = YES; 293 | GCC_WARN_UNUSED_VARIABLE = YES; 294 | IPHONEOS_DEPLOYMENT_TARGET = 11.0; 295 | MTL_ENABLE_DEBUG_INFO = NO; 296 | SDKROOT = iphoneos; 297 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 298 | VALIDATE_PRODUCT = YES; 299 | }; 300 | name = Release; 301 | }; 302 | F42B791F1F6C0B85007D3CDD /* Debug */ = { 303 | isa = XCBuildConfiguration; 304 | buildSettings = { 305 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 306 | CODE_SIGN_STYLE = Automatic; 307 | DEVELOPMENT_TEAM = NR9L6XUP37; 308 | INFOPLIST_FILE = SlideTo/Info.plist; 309 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 310 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 311 | PRODUCT_BUNDLE_IDENTIFIER = com.SlideTo; 312 | PRODUCT_NAME = "$(TARGET_NAME)"; 313 | SWIFT_VERSION = 4.0; 314 | TARGETED_DEVICE_FAMILY = "1,2"; 315 | }; 316 | name = Debug; 317 | }; 318 | F42B79201F6C0B85007D3CDD /* Release */ = { 319 | isa = XCBuildConfiguration; 320 | buildSettings = { 321 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 322 | CODE_SIGN_STYLE = Automatic; 323 | DEVELOPMENT_TEAM = NR9L6XUP37; 324 | INFOPLIST_FILE = SlideTo/Info.plist; 325 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 326 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 327 | PRODUCT_BUNDLE_IDENTIFIER = com.SlideTo; 328 | PRODUCT_NAME = "$(TARGET_NAME)"; 329 | SWIFT_VERSION = 4.0; 330 | TARGETED_DEVICE_FAMILY = "1,2"; 331 | }; 332 | name = Release; 333 | }; 334 | /* End XCBuildConfiguration section */ 335 | 336 | /* Begin XCConfigurationList section */ 337 | F42B79071F6C0B85007D3CDD /* Build configuration list for PBXProject "SlideTo" */ = { 338 | isa = XCConfigurationList; 339 | buildConfigurations = ( 340 | F42B791C1F6C0B85007D3CDD /* Debug */, 341 | F42B791D1F6C0B85007D3CDD /* Release */, 342 | ); 343 | defaultConfigurationIsVisible = 0; 344 | defaultConfigurationName = Release; 345 | }; 346 | F42B791E1F6C0B85007D3CDD /* Build configuration list for PBXNativeTarget "SlideTo" */ = { 347 | isa = XCConfigurationList; 348 | buildConfigurations = ( 349 | F42B791F1F6C0B85007D3CDD /* Debug */, 350 | F42B79201F6C0B85007D3CDD /* Release */, 351 | ); 352 | defaultConfigurationIsVisible = 0; 353 | defaultConfigurationName = Release; 354 | }; 355 | /* End XCConfigurationList section */ 356 | }; 357 | rootObject = F42B79041F6C0B85007D3CDD /* Project object */; 358 | } 359 | -------------------------------------------------------------------------------- /SlideTo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /SlideTo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /SlideTo/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // SlideTo 4 | // 5 | // Created by Christian Moler on 15.09.17. 6 | // Copyright © 2017 Christian Moler. 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 | return true 19 | } 20 | 21 | 22 | 23 | 24 | } 25 | -------------------------------------------------------------------------------- /SlideTo/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | } 88 | ], 89 | "info" : { 90 | "version" : 1, 91 | "author" : "xcode" 92 | } 93 | } -------------------------------------------------------------------------------- /SlideTo/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 | -------------------------------------------------------------------------------- /SlideTo/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 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /SlideTo/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 | -------------------------------------------------------------------------------- /SlideTo/SlideToControl.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SlideToControl.swift 3 | // SlideTo 4 | // 5 | // Created by Christian Moler on 15.09.17. 6 | // Copyright © 2017 Christian Moler. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @IBDesignable 12 | class SlideToControl: UIControl { 13 | 14 | // MARK: Constants 15 | 16 | private struct Constants { 17 | static let thumbInset: CGFloat = 4 18 | static let thumbAnimationSpeed: Double = 0.2 19 | } 20 | 21 | // MARK: Outlets 22 | 23 | @IBOutlet private weak var textLabel: UILabel! 24 | @IBOutlet private weak var thumbView: UIView! 25 | @IBOutlet private weak var leadingThumbConstraint: NSLayoutConstraint! 26 | 27 | // MARK: variables 28 | 29 | private var endXPoint: CGFloat = 0 30 | private var locationInThumb: CGFloat = 0 31 | private var view: UIView? 32 | private var isAnimaionEnabled: Bool = true 33 | weak var delegate: SlideToControlDelegate? 34 | 35 | // MARK: Initializers 36 | 37 | override init(frame: CGRect) { 38 | super.init(frame: frame) 39 | xibSetup() 40 | } 41 | 42 | required init?(coder aDecoder: NSCoder) { 43 | super.init(coder: aDecoder) 44 | xibSetup() 45 | } 46 | 47 | 48 | // MARK: Internal methods 49 | 50 | private func xibSetup() { 51 | view = loadViewFromNib() 52 | view?.frame = bounds 53 | view?.autoresizingMask = [.flexibleWidth, .flexibleHeight] 54 | view?.isUserInteractionEnabled = false 55 | thumbView.isUserInteractionEnabled = false 56 | layoutSubviews() 57 | guard let resultView = view else { return } 58 | addSubview(resultView) 59 | } 60 | 61 | private func loadViewFromNib() -> UIView { 62 | let bundle = Bundle(for: type(of: self)) 63 | let nib = UINib(nibName: "SlideToControl", bundle: bundle) 64 | let view = nib.instantiate(withOwner: self, options: nil)[0] as! UIView 65 | return view 66 | } 67 | 68 | override func layoutSubviews() { 69 | guard let height = view?.frame.height else { return } 70 | guard let width = view?.frame.width else { return } 71 | thumbView.layer.cornerRadius = (height - Constants.thumbInset*2)/2 72 | thumbView.layer.masksToBounds = true 73 | view?.layer.cornerRadius = height/2 74 | view?.layer.masksToBounds = true 75 | endXPoint = width - (height - Constants.thumbInset*2) - Constants.thumbInset 76 | } 77 | 78 | private func updateThumbPositionWith(value: CGFloat) { 79 | leadingThumbConstraint.constant = value 80 | layoutIfNeeded() 81 | } 82 | 83 | private func isTappedOnThumbWith(point: CGPoint) -> Bool { 84 | let x = thumbView.frame.origin.x 85 | let y = thumbView.frame.origin.y 86 | let widthX = thumbView.frame.width + thumbView.frame.origin.x 87 | let heightY = thumbView.frame.height + thumbView.frame.origin.y 88 | if point.x > x && point.x < widthX && point.y > y && point.y < heightY { 89 | return true 90 | } else { 91 | return false 92 | } 93 | } 94 | 95 | 96 | // MARK: override UIControl methods 97 | 98 | override func beginTracking(_ touch: UITouch, with event: UIEvent?) -> Bool { 99 | super.beginTracking(touch, with: event) 100 | locationInThumb = touch.location(in: thumbView).x 101 | let location = touch.location(in: view) 102 | if isTappedOnThumbWith(point: location) { 103 | updateThumbPositionWith(value: location.x - locationInThumb) 104 | return true 105 | } else { 106 | return false 107 | } 108 | } 109 | 110 | override func continueTracking(_ touch: UITouch, with event: UIEvent?) -> Bool { 111 | super.continueTracking(touch, with: event) 112 | let locationX = touch.location(in: view).x - locationInThumb 113 | let locationY = touch.location(in: view).y 114 | if locationX >= endXPoint { 115 | isAnimaionEnabled = false 116 | textLabel.alpha = 0 117 | updateThumbPositionWith(value: endXPoint) 118 | delegate?.sliderCameToEnd() 119 | endTracking(touch, with: event) 120 | return false 121 | } else if locationX < Constants.thumbInset { 122 | isAnimaionEnabled = false 123 | textLabel.alpha = 1 124 | updateThumbPositionWith(value: Constants.thumbInset) 125 | endTracking(touch, with: event) 126 | return false 127 | } else if locationY < 0 || locationY > view!.bounds.height { 128 | isAnimaionEnabled = true 129 | endTracking(touch, with: event) 130 | return false 131 | } 132 | textLabel.alpha = 1 - (locationX / endXPoint) 133 | updateThumbPositionWith(value: locationX) 134 | return true 135 | } 136 | 137 | override func endTracking(_ touch: UITouch?, with event: UIEvent?) { 138 | super.endTracking(touch, with: event) 139 | if isAnimaionEnabled { 140 | UIView.animate(withDuration: Constants.thumbAnimationSpeed) { 141 | self.leadingThumbConstraint.constant = Constants.thumbInset 142 | self.textLabel.alpha = 1 143 | self.layoutIfNeeded() 144 | } 145 | } 146 | isAnimaionEnabled = true 147 | } 148 | } 149 | 150 | // MARK: Inspectable 151 | 152 | extension SlideToControl { 153 | @IBInspectable var thumbColor: UIColor? { 154 | set(color) { 155 | thumbView.backgroundColor = color 156 | } 157 | get { 158 | return thumbView.backgroundColor 159 | } 160 | } 161 | @IBInspectable var bgColor: UIColor? { 162 | set(color) { 163 | view?.backgroundColor = color 164 | } 165 | get { 166 | return view?.backgroundColor 167 | } 168 | } 169 | @IBInspectable var labelColor: UIColor? { 170 | set(color) { 171 | textLabel.textColor = color 172 | } 173 | get { 174 | return textLabel.textColor 175 | } 176 | } 177 | @IBInspectable var labelText: String? { 178 | set(text) { 179 | textLabel.text = text 180 | } 181 | get { 182 | return textLabel.text 183 | } 184 | } 185 | @IBInspectable var labelFontSize: CGFloat { 186 | set(size) { 187 | textLabel.font = UIFont.systemFont(ofSize: size) 188 | } 189 | get { 190 | return textLabel.font.pointSize 191 | } 192 | } 193 | } 194 | 195 | // MARK: Delegate 196 | 197 | protocol SlideToControlDelegate: class { 198 | func sliderCameToEnd() 199 | } 200 | -------------------------------------------------------------------------------- /SlideTo/SlideToControl.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /SlideTo/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // SlideTo 4 | // 5 | // Created by Christian Moler on 15.09.17. 6 | // Copyright © 2017 Christian Moler. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ViewController: UIViewController, SlideToControlDelegate { 12 | @IBOutlet weak var slider: SlideToControl! 13 | override func viewDidLoad() { 14 | super.viewDidLoad() 15 | slider.delegate = self 16 | } 17 | 18 | func sliderCameToEnd() { 19 | let alert: UIAlertController = UIAlertController(title: "Slider", message: "work", preferredStyle: .alert) 20 | let action: UIAlertAction = UIAlertAction(title: "OK", style: .cancel) { _ in 21 | alert.dismiss(animated: true, completion: nil) 22 | } 23 | alert.addAction(action) 24 | present(alert, animated: true, completion: nil) 25 | } 26 | 27 | } 28 | --------------------------------------------------------------------------------