├── .gitignore ├── .swift-version ├── BWSwipeRevealCell.podspec ├── BWSwipeRevealCell.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist ├── xcshareddata │ └── xcschemes │ │ └── BWSwipeRevealCell.xcscheme └── xcuserdata │ └── kylenewsome.xcuserdatad │ └── xcschemes │ ├── BWSwipeRevealCell.xcscheme │ ├── BWSwipeRevealCellExample.xcscheme │ └── xcschememanagement.plist ├── BWSwipeRevealCell ├── BWSwipeCell.swift ├── BWSwipeRevealCell.h ├── BWSwipeRevealCell.swift └── Info.plist ├── BWSwipeRevealCellExample ├── AppDelegate.swift ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ ├── Contents.json │ ├── Delete.imageset │ │ ├── Contents.json │ │ ├── delete-md-@2x.png │ │ └── delete-md.png │ └── Done.imageset │ │ ├── Contents.json │ │ ├── check-md-@2x.png │ │ └── check-md.png ├── BWSwipeRevealCellExample.xcdatamodeld │ ├── .xccurrentversion │ └── BWSwipeRevealCellExample.xcdatamodel │ │ └── contents ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Info.plist └── MasterViewController.swift ├── LICENSE ├── README.md └── example.gif /.gitignore: -------------------------------------------------------------------------------- 1 | ### Xcode ### 2 | build/ 3 | *.pbxuser 4 | !default.pbxuser 5 | *.mode1v3 6 | !default.mode1v3 7 | *.mode2v3 8 | !default.mode2v3 9 | *.perspectivev3 10 | !default.perspectivev3 11 | xcuserdata 12 | *.xccheckout 13 | *.moved-aside 14 | DerivedData 15 | *.hmap 16 | *.ipa 17 | *.xcuserstate 18 | 19 | ### OSX ### 20 | .DS_Store 21 | .AppleDouble 22 | .LSOverride 23 | 24 | # Icon must end with two \r 25 | Icon 26 | 27 | # Thumbnails 28 | ._* 29 | 30 | # Files that might appear in the root of a volume 31 | .DocumentRevisions-V100 32 | .fseventsd 33 | .Spotlight-V100 34 | .TemporaryItems 35 | .Trashes 36 | .VolumeIcon.icns 37 | 38 | # Directories potentially created on remote AFP share 39 | .AppleDB 40 | .AppleDesktop 41 | Network Trash Folder 42 | Temporary Items 43 | .apdisk -------------------------------------------------------------------------------- /.swift-version: -------------------------------------------------------------------------------- 1 | 3.0 2 | -------------------------------------------------------------------------------- /BWSwipeRevealCell.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |spec| 2 | spec.name = 'BWSwipeRevealCell' 3 | spec.version = '3.0.0' 4 | spec.license = { :type => 'BSD' } 5 | spec.homepage = 'https://github.com/bitwit/BWSwipeRevealCell' 6 | spec.authors = { 'Kyle Newsome' => 'kyle@bitwit.ca' } 7 | spec.summary = 'A swipeable table cell with great flexibility' 8 | spec.source = { :git => 'https://github.com/bitwit/BWSwipeRevealCell.git', :tag => '3.0.0' } 9 | spec.source_files = 'BWSwipeRevealCell/BWSwipeRevealCell.h', 'BWSwipeRevealCell/BWSwipeCell.swift', 10 | 'BWSwipeRevealCell/BWSwipeRevealCell.swift' 11 | spec.ios.deployment_target = 8.0 12 | spec.requires_arc = true 13 | spec.social_media_url = "https://twitter.com/kylnew" 14 | end 15 | -------------------------------------------------------------------------------- /BWSwipeRevealCell.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 752EDC641BF64B5B007ED36D /* BWSwipeRevealCell.h in Headers */ = {isa = PBXBuildFile; fileRef = 752EDC631BF64B5B007ED36D /* BWSwipeRevealCell.h */; settings = {ATTRIBUTES = (Public, ); }; }; 11 | 752EDC6F1BF654F8007ED36D /* BWSwipeCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 752EDC6D1BF654F8007ED36D /* BWSwipeCell.swift */; }; 12 | 752EDC701BF654F8007ED36D /* BWSwipeRevealCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 752EDC6E1BF654F8007ED36D /* BWSwipeRevealCell.swift */; }; 13 | 752EDC781BF65880007ED36D /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 752EDC771BF65880007ED36D /* AppDelegate.swift */; }; 14 | 752EDC7B1BF65880007ED36D /* BWSwipeRevealCellExample.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 752EDC791BF65880007ED36D /* BWSwipeRevealCellExample.xcdatamodeld */; }; 15 | 752EDC7D1BF65880007ED36D /* MasterViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 752EDC7C1BF65880007ED36D /* MasterViewController.swift */; }; 16 | 752EDC821BF65880007ED36D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 752EDC801BF65880007ED36D /* Main.storyboard */; }; 17 | 752EDC871BF65880007ED36D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 752EDC851BF65880007ED36D /* LaunchScreen.storyboard */; }; 18 | 752EDC8D1BF659C7007ED36D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 752EDC8C1BF659C7007ED36D /* Assets.xcassets */; }; 19 | 75ABE4201C0F88AD00F42894 /* BWSwipeRevealCell.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 752EDC601BF64B5B007ED36D /* BWSwipeRevealCell.framework */; }; 20 | 75ABE4221C0F8AF300F42894 /* BWSwipeRevealCell.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 752EDC601BF64B5B007ED36D /* BWSwipeRevealCell.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 21 | /* End PBXBuildFile section */ 22 | 23 | /* Begin PBXContainerItemProxy section */ 24 | 75ABE4231C0F8AF300F42894 /* PBXContainerItemProxy */ = { 25 | isa = PBXContainerItemProxy; 26 | containerPortal = 752EDC571BF64B5B007ED36D /* Project object */; 27 | proxyType = 1; 28 | remoteGlobalIDString = 752EDC5F1BF64B5B007ED36D; 29 | remoteInfo = BWSwipeRevealCell; 30 | }; 31 | /* End PBXContainerItemProxy section */ 32 | 33 | /* Begin PBXCopyFilesBuildPhase section */ 34 | 75ABE4251C0F8AF300F42894 /* Embed Frameworks */ = { 35 | isa = PBXCopyFilesBuildPhase; 36 | buildActionMask = 2147483647; 37 | dstPath = ""; 38 | dstSubfolderSpec = 10; 39 | files = ( 40 | 75ABE4221C0F8AF300F42894 /* BWSwipeRevealCell.framework in Embed Frameworks */, 41 | ); 42 | name = "Embed Frameworks"; 43 | runOnlyForDeploymentPostprocessing = 0; 44 | }; 45 | /* End PBXCopyFilesBuildPhase section */ 46 | 47 | /* Begin PBXFileReference section */ 48 | 752EDC601BF64B5B007ED36D /* BWSwipeRevealCell.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = BWSwipeRevealCell.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 49 | 752EDC631BF64B5B007ED36D /* BWSwipeRevealCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BWSwipeRevealCell.h; sourceTree = ""; }; 50 | 752EDC651BF64B5B007ED36D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 51 | 752EDC6B1BF65169007ED36D /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = ""; }; 52 | 752EDC6D1BF654F8007ED36D /* BWSwipeCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BWSwipeCell.swift; sourceTree = ""; }; 53 | 752EDC6E1BF654F8007ED36D /* BWSwipeRevealCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BWSwipeRevealCell.swift; sourceTree = ""; }; 54 | 752EDC751BF65880007ED36D /* BWSwipeRevealCellExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = BWSwipeRevealCellExample.app; sourceTree = BUILT_PRODUCTS_DIR; }; 55 | 752EDC771BF65880007ED36D /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 56 | 752EDC7A1BF65880007ED36D /* BWSwipeRevealCellExample.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = BWSwipeRevealCellExample.xcdatamodel; sourceTree = ""; }; 57 | 752EDC7C1BF65880007ED36D /* MasterViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MasterViewController.swift; sourceTree = ""; }; 58 | 752EDC811BF65880007ED36D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 59 | 752EDC861BF65880007ED36D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 60 | 752EDC881BF65880007ED36D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 61 | 752EDC8C1BF659C7007ED36D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 62 | 752EDC8E1BF65C68007ED36D /* example.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; path = example.gif; sourceTree = ""; }; 63 | /* End PBXFileReference section */ 64 | 65 | /* Begin PBXFrameworksBuildPhase section */ 66 | 752EDC5C1BF64B5B007ED36D /* Frameworks */ = { 67 | isa = PBXFrameworksBuildPhase; 68 | buildActionMask = 2147483647; 69 | files = ( 70 | ); 71 | runOnlyForDeploymentPostprocessing = 0; 72 | }; 73 | 752EDC721BF65880007ED36D /* Frameworks */ = { 74 | isa = PBXFrameworksBuildPhase; 75 | buildActionMask = 2147483647; 76 | files = ( 77 | 75ABE4201C0F88AD00F42894 /* BWSwipeRevealCell.framework in Frameworks */, 78 | ); 79 | runOnlyForDeploymentPostprocessing = 0; 80 | }; 81 | /* End PBXFrameworksBuildPhase section */ 82 | 83 | /* Begin PBXGroup section */ 84 | 752EDC561BF64B5B007ED36D = { 85 | isa = PBXGroup; 86 | children = ( 87 | 752EDC8E1BF65C68007ED36D /* example.gif */, 88 | 752EDC6B1BF65169007ED36D /* README.md */, 89 | 752EDC621BF64B5B007ED36D /* BWSwipeRevealCell */, 90 | 752EDC761BF65880007ED36D /* BWSwipeRevealCellExample */, 91 | 752EDC611BF64B5B007ED36D /* Products */, 92 | ); 93 | sourceTree = ""; 94 | }; 95 | 752EDC611BF64B5B007ED36D /* Products */ = { 96 | isa = PBXGroup; 97 | children = ( 98 | 752EDC601BF64B5B007ED36D /* BWSwipeRevealCell.framework */, 99 | 752EDC751BF65880007ED36D /* BWSwipeRevealCellExample.app */, 100 | ); 101 | name = Products; 102 | sourceTree = ""; 103 | }; 104 | 752EDC621BF64B5B007ED36D /* BWSwipeRevealCell */ = { 105 | isa = PBXGroup; 106 | children = ( 107 | 752EDC6D1BF654F8007ED36D /* BWSwipeCell.swift */, 108 | 752EDC6E1BF654F8007ED36D /* BWSwipeRevealCell.swift */, 109 | 752EDC631BF64B5B007ED36D /* BWSwipeRevealCell.h */, 110 | 752EDC651BF64B5B007ED36D /* Info.plist */, 111 | ); 112 | path = BWSwipeRevealCell; 113 | sourceTree = ""; 114 | }; 115 | 752EDC761BF65880007ED36D /* BWSwipeRevealCellExample */ = { 116 | isa = PBXGroup; 117 | children = ( 118 | 752EDC8C1BF659C7007ED36D /* Assets.xcassets */, 119 | 752EDC771BF65880007ED36D /* AppDelegate.swift */, 120 | 752EDC7C1BF65880007ED36D /* MasterViewController.swift */, 121 | 752EDC801BF65880007ED36D /* Main.storyboard */, 122 | 752EDC851BF65880007ED36D /* LaunchScreen.storyboard */, 123 | 752EDC881BF65880007ED36D /* Info.plist */, 124 | 752EDC791BF65880007ED36D /* BWSwipeRevealCellExample.xcdatamodeld */, 125 | ); 126 | path = BWSwipeRevealCellExample; 127 | sourceTree = ""; 128 | }; 129 | /* End PBXGroup section */ 130 | 131 | /* Begin PBXHeadersBuildPhase section */ 132 | 752EDC5D1BF64B5B007ED36D /* Headers */ = { 133 | isa = PBXHeadersBuildPhase; 134 | buildActionMask = 2147483647; 135 | files = ( 136 | 752EDC641BF64B5B007ED36D /* BWSwipeRevealCell.h in Headers */, 137 | ); 138 | runOnlyForDeploymentPostprocessing = 0; 139 | }; 140 | /* End PBXHeadersBuildPhase section */ 141 | 142 | /* Begin PBXNativeTarget section */ 143 | 752EDC5F1BF64B5B007ED36D /* BWSwipeRevealCell */ = { 144 | isa = PBXNativeTarget; 145 | buildConfigurationList = 752EDC681BF64B5B007ED36D /* Build configuration list for PBXNativeTarget "BWSwipeRevealCell" */; 146 | buildPhases = ( 147 | 752EDC5B1BF64B5B007ED36D /* Sources */, 148 | 752EDC5C1BF64B5B007ED36D /* Frameworks */, 149 | 752EDC5D1BF64B5B007ED36D /* Headers */, 150 | 752EDC5E1BF64B5B007ED36D /* Resources */, 151 | ); 152 | buildRules = ( 153 | ); 154 | dependencies = ( 155 | ); 156 | name = BWSwipeRevealCell; 157 | productName = BWSwipeRevealCell; 158 | productReference = 752EDC601BF64B5B007ED36D /* BWSwipeRevealCell.framework */; 159 | productType = "com.apple.product-type.framework"; 160 | }; 161 | 752EDC741BF65880007ED36D /* BWSwipeRevealCellExample */ = { 162 | isa = PBXNativeTarget; 163 | buildConfigurationList = 752EDC8B1BF65880007ED36D /* Build configuration list for PBXNativeTarget "BWSwipeRevealCellExample" */; 164 | buildPhases = ( 165 | 752EDC711BF65880007ED36D /* Sources */, 166 | 752EDC721BF65880007ED36D /* Frameworks */, 167 | 752EDC731BF65880007ED36D /* Resources */, 168 | 75ABE4251C0F8AF300F42894 /* Embed Frameworks */, 169 | ); 170 | buildRules = ( 171 | ); 172 | dependencies = ( 173 | 75ABE4241C0F8AF300F42894 /* PBXTargetDependency */, 174 | ); 175 | name = BWSwipeRevealCellExample; 176 | productName = BWSwipeRevealCellExample; 177 | productReference = 752EDC751BF65880007ED36D /* BWSwipeRevealCellExample.app */; 178 | productType = "com.apple.product-type.application"; 179 | }; 180 | /* End PBXNativeTarget section */ 181 | 182 | /* Begin PBXProject section */ 183 | 752EDC571BF64B5B007ED36D /* Project object */ = { 184 | isa = PBXProject; 185 | attributes = { 186 | LastSwiftUpdateCheck = 0710; 187 | LastUpgradeCheck = 1020; 188 | ORGANIZATIONNAME = "Kyle Newsome"; 189 | TargetAttributes = { 190 | 752EDC5F1BF64B5B007ED36D = { 191 | CreatedOnToolsVersion = 7.1; 192 | LastSwiftMigration = 1020; 193 | }; 194 | 752EDC741BF65880007ED36D = { 195 | CreatedOnToolsVersion = 7.1; 196 | LastSwiftMigration = 1020; 197 | }; 198 | }; 199 | }; 200 | buildConfigurationList = 752EDC5A1BF64B5B007ED36D /* Build configuration list for PBXProject "BWSwipeRevealCell" */; 201 | compatibilityVersion = "Xcode 3.2"; 202 | developmentRegion = en; 203 | hasScannedForEncodings = 0; 204 | knownRegions = ( 205 | en, 206 | Base, 207 | ); 208 | mainGroup = 752EDC561BF64B5B007ED36D; 209 | productRefGroup = 752EDC611BF64B5B007ED36D /* Products */; 210 | projectDirPath = ""; 211 | projectRoot = ""; 212 | targets = ( 213 | 752EDC5F1BF64B5B007ED36D /* BWSwipeRevealCell */, 214 | 752EDC741BF65880007ED36D /* BWSwipeRevealCellExample */, 215 | ); 216 | }; 217 | /* End PBXProject section */ 218 | 219 | /* Begin PBXResourcesBuildPhase section */ 220 | 752EDC5E1BF64B5B007ED36D /* Resources */ = { 221 | isa = PBXResourcesBuildPhase; 222 | buildActionMask = 2147483647; 223 | files = ( 224 | ); 225 | runOnlyForDeploymentPostprocessing = 0; 226 | }; 227 | 752EDC731BF65880007ED36D /* Resources */ = { 228 | isa = PBXResourcesBuildPhase; 229 | buildActionMask = 2147483647; 230 | files = ( 231 | 752EDC871BF65880007ED36D /* LaunchScreen.storyboard in Resources */, 232 | 752EDC8D1BF659C7007ED36D /* Assets.xcassets in Resources */, 233 | 752EDC821BF65880007ED36D /* Main.storyboard in Resources */, 234 | ); 235 | runOnlyForDeploymentPostprocessing = 0; 236 | }; 237 | /* End PBXResourcesBuildPhase section */ 238 | 239 | /* Begin PBXSourcesBuildPhase section */ 240 | 752EDC5B1BF64B5B007ED36D /* Sources */ = { 241 | isa = PBXSourcesBuildPhase; 242 | buildActionMask = 2147483647; 243 | files = ( 244 | 752EDC701BF654F8007ED36D /* BWSwipeRevealCell.swift in Sources */, 245 | 752EDC6F1BF654F8007ED36D /* BWSwipeCell.swift in Sources */, 246 | ); 247 | runOnlyForDeploymentPostprocessing = 0; 248 | }; 249 | 752EDC711BF65880007ED36D /* Sources */ = { 250 | isa = PBXSourcesBuildPhase; 251 | buildActionMask = 2147483647; 252 | files = ( 253 | 752EDC781BF65880007ED36D /* AppDelegate.swift in Sources */, 254 | 752EDC7B1BF65880007ED36D /* BWSwipeRevealCellExample.xcdatamodeld in Sources */, 255 | 752EDC7D1BF65880007ED36D /* MasterViewController.swift in Sources */, 256 | ); 257 | runOnlyForDeploymentPostprocessing = 0; 258 | }; 259 | /* End PBXSourcesBuildPhase section */ 260 | 261 | /* Begin PBXTargetDependency section */ 262 | 75ABE4241C0F8AF300F42894 /* PBXTargetDependency */ = { 263 | isa = PBXTargetDependency; 264 | target = 752EDC5F1BF64B5B007ED36D /* BWSwipeRevealCell */; 265 | targetProxy = 75ABE4231C0F8AF300F42894 /* PBXContainerItemProxy */; 266 | }; 267 | /* End PBXTargetDependency section */ 268 | 269 | /* Begin PBXVariantGroup section */ 270 | 752EDC801BF65880007ED36D /* Main.storyboard */ = { 271 | isa = PBXVariantGroup; 272 | children = ( 273 | 752EDC811BF65880007ED36D /* Base */, 274 | ); 275 | name = Main.storyboard; 276 | sourceTree = ""; 277 | }; 278 | 752EDC851BF65880007ED36D /* LaunchScreen.storyboard */ = { 279 | isa = PBXVariantGroup; 280 | children = ( 281 | 752EDC861BF65880007ED36D /* Base */, 282 | ); 283 | name = LaunchScreen.storyboard; 284 | sourceTree = ""; 285 | }; 286 | /* End PBXVariantGroup section */ 287 | 288 | /* Begin XCBuildConfiguration section */ 289 | 752EDC661BF64B5B007ED36D /* Debug */ = { 290 | isa = XCBuildConfiguration; 291 | buildSettings = { 292 | ALWAYS_SEARCH_USER_PATHS = NO; 293 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; 294 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 295 | CLANG_CXX_LIBRARY = "libc++"; 296 | CLANG_ENABLE_MODULES = YES; 297 | CLANG_ENABLE_OBJC_ARC = YES; 298 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 299 | CLANG_WARN_BOOL_CONVERSION = YES; 300 | CLANG_WARN_COMMA = YES; 301 | CLANG_WARN_CONSTANT_CONVERSION = YES; 302 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 303 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 304 | CLANG_WARN_EMPTY_BODY = YES; 305 | CLANG_WARN_ENUM_CONVERSION = YES; 306 | CLANG_WARN_INFINITE_RECURSION = YES; 307 | CLANG_WARN_INT_CONVERSION = YES; 308 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 309 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 310 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 311 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 312 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 313 | CLANG_WARN_STRICT_PROTOTYPES = YES; 314 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 315 | CLANG_WARN_UNREACHABLE_CODE = YES; 316 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 317 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 318 | COPY_PHASE_STRIP = NO; 319 | CURRENT_PROJECT_VERSION = 1; 320 | DEBUG_INFORMATION_FORMAT = dwarf; 321 | ENABLE_STRICT_OBJC_MSGSEND = YES; 322 | ENABLE_TESTABILITY = YES; 323 | GCC_C_LANGUAGE_STANDARD = gnu99; 324 | GCC_DYNAMIC_NO_PIC = NO; 325 | GCC_NO_COMMON_BLOCKS = YES; 326 | GCC_OPTIMIZATION_LEVEL = 0; 327 | GCC_PREPROCESSOR_DEFINITIONS = ( 328 | "DEBUG=1", 329 | "$(inherited)", 330 | ); 331 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 332 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 333 | GCC_WARN_UNDECLARED_SELECTOR = YES; 334 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 335 | GCC_WARN_UNUSED_FUNCTION = YES; 336 | GCC_WARN_UNUSED_VARIABLE = YES; 337 | IPHONEOS_DEPLOYMENT_TARGET = 10.3; 338 | MTL_ENABLE_DEBUG_INFO = YES; 339 | ONLY_ACTIVE_ARCH = YES; 340 | SDKROOT = iphoneos; 341 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 342 | TARGETED_DEVICE_FAMILY = "1,2"; 343 | VERSIONING_SYSTEM = "apple-generic"; 344 | VERSION_INFO_PREFIX = ""; 345 | }; 346 | name = Debug; 347 | }; 348 | 752EDC671BF64B5B007ED36D /* Release */ = { 349 | isa = XCBuildConfiguration; 350 | buildSettings = { 351 | ALWAYS_SEARCH_USER_PATHS = NO; 352 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; 353 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 354 | CLANG_CXX_LIBRARY = "libc++"; 355 | CLANG_ENABLE_MODULES = YES; 356 | CLANG_ENABLE_OBJC_ARC = YES; 357 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 358 | CLANG_WARN_BOOL_CONVERSION = YES; 359 | CLANG_WARN_COMMA = YES; 360 | CLANG_WARN_CONSTANT_CONVERSION = YES; 361 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 362 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 363 | CLANG_WARN_EMPTY_BODY = YES; 364 | CLANG_WARN_ENUM_CONVERSION = YES; 365 | CLANG_WARN_INFINITE_RECURSION = YES; 366 | CLANG_WARN_INT_CONVERSION = YES; 367 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 368 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 369 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 370 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 371 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 372 | CLANG_WARN_STRICT_PROTOTYPES = YES; 373 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 374 | CLANG_WARN_UNREACHABLE_CODE = YES; 375 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 376 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 377 | COPY_PHASE_STRIP = NO; 378 | CURRENT_PROJECT_VERSION = 1; 379 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 380 | ENABLE_NS_ASSERTIONS = NO; 381 | ENABLE_STRICT_OBJC_MSGSEND = YES; 382 | GCC_C_LANGUAGE_STANDARD = gnu99; 383 | GCC_NO_COMMON_BLOCKS = YES; 384 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 385 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 386 | GCC_WARN_UNDECLARED_SELECTOR = YES; 387 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 388 | GCC_WARN_UNUSED_FUNCTION = YES; 389 | GCC_WARN_UNUSED_VARIABLE = YES; 390 | IPHONEOS_DEPLOYMENT_TARGET = 10.3; 391 | MTL_ENABLE_DEBUG_INFO = NO; 392 | SDKROOT = iphoneos; 393 | SWIFT_COMPILATION_MODE = wholemodule; 394 | TARGETED_DEVICE_FAMILY = "1,2"; 395 | VALIDATE_PRODUCT = YES; 396 | VERSIONING_SYSTEM = "apple-generic"; 397 | VERSION_INFO_PREFIX = ""; 398 | }; 399 | name = Release; 400 | }; 401 | 752EDC691BF64B5B007ED36D /* Debug */ = { 402 | isa = XCBuildConfiguration; 403 | buildSettings = { 404 | CODE_SIGN_IDENTITY = ""; 405 | DEFINES_MODULE = YES; 406 | DYLIB_COMPATIBILITY_VERSION = 1; 407 | DYLIB_CURRENT_VERSION = 1; 408 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 409 | INFOPLIST_FILE = BWSwipeRevealCell/Info.plist; 410 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 411 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 412 | PRODUCT_BUNDLE_IDENTIFIER = ca.bitwit.BWSwipeRevealCell; 413 | PRODUCT_NAME = "$(TARGET_NAME)"; 414 | SKIP_INSTALL = YES; 415 | SWIFT_VERSION = 5.0; 416 | }; 417 | name = Debug; 418 | }; 419 | 752EDC6A1BF64B5B007ED36D /* Release */ = { 420 | isa = XCBuildConfiguration; 421 | buildSettings = { 422 | CODE_SIGN_IDENTITY = ""; 423 | DEFINES_MODULE = YES; 424 | DYLIB_COMPATIBILITY_VERSION = 1; 425 | DYLIB_CURRENT_VERSION = 1; 426 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 427 | INFOPLIST_FILE = BWSwipeRevealCell/Info.plist; 428 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 429 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 430 | PRODUCT_BUNDLE_IDENTIFIER = ca.bitwit.BWSwipeRevealCell; 431 | PRODUCT_NAME = "$(TARGET_NAME)"; 432 | SKIP_INSTALL = YES; 433 | SWIFT_VERSION = 5.0; 434 | }; 435 | name = Release; 436 | }; 437 | 752EDC891BF65880007ED36D /* Debug */ = { 438 | isa = XCBuildConfiguration; 439 | buildSettings = { 440 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 441 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 442 | INFOPLIST_FILE = BWSwipeRevealCellExample/Info.plist; 443 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 444 | PRODUCT_BUNDLE_IDENTIFIER = ca.bitwit.BWSwipeRevealCellExample; 445 | PRODUCT_NAME = "$(TARGET_NAME)"; 446 | SWIFT_VERSION = 5.0; 447 | }; 448 | name = Debug; 449 | }; 450 | 752EDC8A1BF65880007ED36D /* Release */ = { 451 | isa = XCBuildConfiguration; 452 | buildSettings = { 453 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 454 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 455 | INFOPLIST_FILE = BWSwipeRevealCellExample/Info.plist; 456 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 457 | PRODUCT_BUNDLE_IDENTIFIER = ca.bitwit.BWSwipeRevealCellExample; 458 | PRODUCT_NAME = "$(TARGET_NAME)"; 459 | SWIFT_VERSION = 5.0; 460 | }; 461 | name = Release; 462 | }; 463 | /* End XCBuildConfiguration section */ 464 | 465 | /* Begin XCConfigurationList section */ 466 | 752EDC5A1BF64B5B007ED36D /* Build configuration list for PBXProject "BWSwipeRevealCell" */ = { 467 | isa = XCConfigurationList; 468 | buildConfigurations = ( 469 | 752EDC661BF64B5B007ED36D /* Debug */, 470 | 752EDC671BF64B5B007ED36D /* Release */, 471 | ); 472 | defaultConfigurationIsVisible = 0; 473 | defaultConfigurationName = Release; 474 | }; 475 | 752EDC681BF64B5B007ED36D /* Build configuration list for PBXNativeTarget "BWSwipeRevealCell" */ = { 476 | isa = XCConfigurationList; 477 | buildConfigurations = ( 478 | 752EDC691BF64B5B007ED36D /* Debug */, 479 | 752EDC6A1BF64B5B007ED36D /* Release */, 480 | ); 481 | defaultConfigurationIsVisible = 0; 482 | defaultConfigurationName = Release; 483 | }; 484 | 752EDC8B1BF65880007ED36D /* Build configuration list for PBXNativeTarget "BWSwipeRevealCellExample" */ = { 485 | isa = XCConfigurationList; 486 | buildConfigurations = ( 487 | 752EDC891BF65880007ED36D /* Debug */, 488 | 752EDC8A1BF65880007ED36D /* Release */, 489 | ); 490 | defaultConfigurationIsVisible = 0; 491 | defaultConfigurationName = Release; 492 | }; 493 | /* End XCConfigurationList section */ 494 | 495 | /* Begin XCVersionGroup section */ 496 | 752EDC791BF65880007ED36D /* BWSwipeRevealCellExample.xcdatamodeld */ = { 497 | isa = XCVersionGroup; 498 | children = ( 499 | 752EDC7A1BF65880007ED36D /* BWSwipeRevealCellExample.xcdatamodel */, 500 | ); 501 | currentVersion = 752EDC7A1BF65880007ED36D /* BWSwipeRevealCellExample.xcdatamodel */; 502 | path = BWSwipeRevealCellExample.xcdatamodeld; 503 | sourceTree = ""; 504 | versionGroupType = wrapper.xcdatamodel; 505 | }; 506 | /* End XCVersionGroup section */ 507 | }; 508 | rootObject = 752EDC571BF64B5B007ED36D /* Project object */; 509 | } 510 | -------------------------------------------------------------------------------- /BWSwipeRevealCell.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /BWSwipeRevealCell.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /BWSwipeRevealCell.xcodeproj/xcshareddata/xcschemes/BWSwipeRevealCell.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 34 | 35 | 45 | 46 | 52 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 70 | 71 | 72 | 73 | 75 | 76 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /BWSwipeRevealCell.xcodeproj/xcuserdata/kylenewsome.xcuserdatad/xcschemes/BWSwipeRevealCell.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 34 | 35 | 45 | 46 | 52 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 70 | 71 | 72 | 73 | 75 | 76 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /BWSwipeRevealCell.xcodeproj/xcuserdata/kylenewsome.xcuserdatad/xcschemes/BWSwipeRevealCellExample.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /BWSwipeRevealCell.xcodeproj/xcuserdata/kylenewsome.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | BWSwipeRevealCell.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | BWSwipeRevealCellExample.xcscheme 13 | 14 | orderHint 15 | 1 16 | 17 | 18 | SuppressBuildableAutocreation 19 | 20 | 752EDC5F1BF64B5B007ED36D 21 | 22 | primary 23 | 24 | 25 | 752EDC741BF65880007ED36D 26 | 27 | primary 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /BWSwipeRevealCell/BWSwipeCell.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BWSwipeCell.swift 3 | // BWSwipeCell 4 | // 5 | // Created by Kyle Newsome on 2015-10-20. 6 | // Copyright © 2015 Kyle Newsome. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import UIKit 11 | 12 | //Defines the interaction type of the table cell 13 | public enum BWSwipeCellType: Int { 14 | case swipeThrough = 0 // swipes with finger and animates through 15 | case springRelease // resists pulling and bounces back 16 | case slidingDoor // swipe to a stopping position where underlying buttons can be revealed 17 | } 18 | 19 | public enum BWSwipeCellRevealDirection { 20 | case none 21 | case both 22 | case right 23 | case left 24 | } 25 | 26 | public enum BWSwipeCellState { 27 | case normal 28 | case pastThresholdLeft 29 | case pastThresholdRight 30 | } 31 | 32 | @objc public protocol BWSwipeCellDelegate: NSObjectProtocol { 33 | @objc optional func swipeCellDidStartSwiping(_ cell: BWSwipeCell) 34 | @objc optional func swipeCellDidSwipe(_ cell: BWSwipeCell) 35 | @objc optional func swipeCellWillRelease(_ cell: BWSwipeCell) 36 | @objc optional func swipeCellDidCompleteRelease(_ cell: BWSwipeCell) 37 | @objc optional func swipeCellDidChangeState(_ cell: BWSwipeCell) 38 | } 39 | 40 | open class BWSwipeCell:UITableViewCell { 41 | 42 | // The interaction type for this table cell 43 | open var type:BWSwipeCellType = .springRelease 44 | 45 | // The allowable swipe direction(s) 46 | open var revealDirection: BWSwipeCellRevealDirection = .both 47 | 48 | // The current state of the cell (either normal or past a threshold) 49 | open fileprivate(set) var state: BWSwipeCellState = .normal 50 | 51 | // The point at which pan elasticity starts, and `state` changes. Defaults to the height of the `UITableViewCell` (i.e. when it form a perfect square) 52 | open lazy var threshold: CGFloat = { 53 | return self.frame.height 54 | }() 55 | 56 | // A number between 0 and 1 to indicate progress toward reaching threshold in the current swiping direction. Useful for changing UI gradually as the user swipes. 57 | open var progress: CGFloat { 58 | get { 59 | let progress = abs(self.contentView.frame.origin.x) / self.threshold 60 | return (progress > 1) ? 1 : progress 61 | } 62 | } 63 | 64 | // Should we allow the cell to be pulled past the threshold at all? (.SwipeThrough cells will ignore this) 65 | open var shouldExceedThreshold: Bool = true 66 | 67 | // Control how much elastic resistance there is past threshold, if it can be exceeded. Default is `0.7` and `1.0` would mean no elastic resistance 68 | open var panElasticityFactor: CGFloat = 0.7 69 | 70 | // Length of the animation on release 71 | open var animationDuration: Double = 0.2 72 | 73 | // BWSwipeCell Delegate 74 | open weak var delegate: BWSwipeCellDelegate? 75 | 76 | open lazy var releaseCompletionBlock:((Bool) -> Void)? = { 77 | return { 78 | [weak self] (finished: Bool) in 79 | 80 | guard let this = self else { return } 81 | 82 | this.delegate?.swipeCellDidCompleteRelease?(this) 83 | this.cleanUp() 84 | } 85 | }() 86 | 87 | // MARK: - Swipe Cell Functions 88 | 89 | open func initialize() { 90 | self.selectionStyle = .none 91 | self.contentView.backgroundColor = UIColor.white 92 | let panGestureRecognizer: UIPanGestureRecognizer = UIPanGestureRecognizer(target: self, action: #selector(BWSwipeCell.handlePanGesture(_:))) 93 | panGestureRecognizer.delegate = self 94 | self.addGestureRecognizer(panGestureRecognizer) 95 | 96 | let backgroundView: UIView = UIView(frame: self.frame) 97 | backgroundView.backgroundColor = UIColor.white 98 | self.backgroundView = backgroundView 99 | } 100 | 101 | open func cleanUp() { 102 | self.state = .normal 103 | } 104 | 105 | @objc open func handlePanGesture(_ panGestureRecognizer: UIPanGestureRecognizer) { 106 | let translation: CGPoint = panGestureRecognizer.translation(in: panGestureRecognizer.view) 107 | var panOffset: CGFloat = translation.x 108 | 109 | // If we have elasticity to consider, do some extra calculations for panOffset 110 | if self.type != .swipeThrough && abs(translation.x) > self.threshold { 111 | if self.shouldExceedThreshold { 112 | let offset: CGFloat = abs(translation.x) 113 | panOffset = offset - ((offset - self.threshold) * self.panElasticityFactor) 114 | panOffset *= translation.x < 0 ? -1.0 : 1.0 115 | } else { 116 | // If we don't allow exceeding the threshold 117 | panOffset = translation.x < 0 ? -self.threshold : self.threshold 118 | } 119 | } 120 | 121 | // Start, continue or complete the swipe gesture 122 | let actualTranslation: CGPoint = CGPoint(x: panOffset, y: translation.y) 123 | if panGestureRecognizer.state == .began && panGestureRecognizer.numberOfTouches > 0 { 124 | let newTranslation = CGPoint(x: self.contentView.frame.origin.x, y: 0) 125 | panGestureRecognizer.setTranslation(newTranslation, in: panGestureRecognizer.view) 126 | self.didStartSwiping() 127 | self.animateContentViewForPoint(newTranslation) 128 | } 129 | else { 130 | if panGestureRecognizer.state == .changed && panGestureRecognizer.numberOfTouches > 0 { 131 | self.animateContentViewForPoint(actualTranslation) 132 | } 133 | else { 134 | self.resetCellPosition() 135 | } 136 | } 137 | } 138 | 139 | open func didStartSwiping() { 140 | self.delegate?.swipeCellDidStartSwiping?(self) 141 | } 142 | 143 | open func animateContentViewForPoint(_ point: CGPoint) { 144 | if (point.x > 0 && self.revealDirection == .left) || (point.x < 0 && self.revealDirection == .right) || self.revealDirection == .both { 145 | self.contentView.frame = self.contentView.bounds.offsetBy(dx: point.x, dy: 0) 146 | let previousState = state 147 | if point.x >= self.threshold { 148 | self.state = .pastThresholdLeft 149 | } 150 | else if point.x < -self.threshold { 151 | self.state = .pastThresholdRight 152 | } 153 | else { 154 | self.state = .normal 155 | } 156 | 157 | if self.state != previousState { 158 | self.delegate?.swipeCellDidChangeState?(self) 159 | } 160 | self.delegate?.swipeCellDidSwipe?(self) 161 | } 162 | else { 163 | if (point.x > 0 && self.revealDirection == .right) || (point.x < 0 && self.revealDirection == .left) { 164 | self.contentView.frame = self.contentView.bounds.offsetBy(dx: 0, dy: 0) 165 | } 166 | } 167 | } 168 | 169 | open func resetCellPosition() { 170 | self.delegate?.swipeCellWillRelease?(self) 171 | if self.type == .springRelease || self.state == .normal { 172 | self.animateCellSpringRelease() 173 | } else if self.type == .slidingDoor { 174 | self.animateCellSlidingDoor() 175 | } else { 176 | self.animateCellSwipeThrough() 177 | } 178 | } 179 | 180 | // MARK: - Reset animations 181 | 182 | open func animateCellSpringRelease() { 183 | UIView.animate(withDuration: self.animationDuration, 184 | delay: 0, 185 | options: .curveEaseOut, 186 | animations: { 187 | self.contentView.frame = self.contentView.bounds 188 | }, 189 | completion: self.releaseCompletionBlock) 190 | } 191 | 192 | open func animateCellSlidingDoor() { 193 | UIView.animate(withDuration: self.animationDuration, 194 | delay: 0, 195 | options: .allowUserInteraction, 196 | animations: { 197 | let pointX = self.contentView.frame.origin.x 198 | if pointX > 0 { 199 | self.contentView.frame.origin.x = self.threshold 200 | } else if pointX < 0 { 201 | self.contentView.frame.origin.x = -self.threshold 202 | } 203 | }, 204 | completion: self.releaseCompletionBlock) 205 | } 206 | 207 | open func animateCellSwipeThrough() { 208 | UIView.animate(withDuration: self.animationDuration, 209 | delay: 0, 210 | options: UIView.AnimationOptions.curveLinear, 211 | animations: { 212 | let direction:CGFloat = (self.contentView.frame.origin.x > 0) ? 1 : -1 213 | self.contentView.frame.origin.x = direction * (self.contentView.bounds.width + self.threshold) 214 | }, completion: self.releaseCompletionBlock) 215 | } 216 | 217 | // MARK: - UITableViewCell Overrides 218 | 219 | public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { 220 | super.init(style: style, reuseIdentifier: reuseIdentifier) 221 | self.initialize() 222 | } 223 | 224 | public required init?(coder aDecoder: NSCoder) { 225 | super.init(coder: aDecoder) 226 | self.initialize() 227 | } 228 | 229 | open override func prepareForReuse() { 230 | super.prepareForReuse() 231 | self.cleanUp() 232 | } 233 | 234 | open override func setSelected(_ selected: Bool, animated: Bool) { 235 | super.setSelected(selected, animated: animated) 236 | } 237 | 238 | open override func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool { 239 | if gestureRecognizer.isKind(of: UIPanGestureRecognizer.self) && self.revealDirection != .none { 240 | let pan:UIPanGestureRecognizer = gestureRecognizer as! UIPanGestureRecognizer 241 | let translation: CGPoint = pan.translation(in: self.superview) 242 | return (abs(translation.x) / abs(translation.y) > 1) ? true : false 243 | } 244 | return false 245 | } 246 | } 247 | -------------------------------------------------------------------------------- /BWSwipeRevealCell/BWSwipeRevealCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // BWSwipeRevealCell.h 3 | // BWSwipeRevealCell 4 | // 5 | // Created by Kyle Newsome on 2015-11-13. 6 | // Copyright © 2015 Kyle Newsome. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for BWSwipeRevealCell. 12 | FOUNDATION_EXPORT double BWSwipeRevealCellVersionNumber; 13 | 14 | //! Project version string for BWSwipeRevealCell. 15 | FOUNDATION_EXPORT const unsigned char BWSwipeRevealCellVersionString[]; 16 | 17 | // In this header, you should import all the public headers of your framework using statements like #import 18 | 19 | 20 | -------------------------------------------------------------------------------- /BWSwipeRevealCell/BWSwipeRevealCell.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BWSwipeRevealCell.swift 3 | // BWSwipeCell 4 | // 5 | // Created by Kyle Newsome on 2015-11-10. 6 | // Copyright © 2015 Kyle Newsome. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import UIKit 11 | 12 | @objc public protocol BWSwipeRevealCellDelegate:BWSwipeCellDelegate { 13 | @objc optional func swipeCellActivatedAction(_ cell: BWSwipeCell, isActionLeft: Bool) 14 | } 15 | 16 | open class BWSwipeRevealCell: BWSwipeCell { 17 | 18 | open var backViewbackgroundColor: UIColor = UIColor(white: 0.92, alpha: 1) 19 | fileprivate var _backView: UIView? 20 | open var backView: UIView? { 21 | if _backView == nil { 22 | _backView = UIView(frame: self.contentView.bounds) 23 | _backView!.backgroundColor = self.backViewbackgroundColor 24 | } 25 | return _backView 26 | } 27 | open var shouldCleanUpBackView = true 28 | 29 | open var bgViewInactiveColor: UIColor = UIColor.gray 30 | open var bgViewLeftColor: UIColor = UIColor(red: 0.5, green: 0.5, blue: 0.5, alpha: 1) 31 | open var bgViewRightColor: UIColor = UIColor(red: 0.5, green: 0.5, blue: 0.5, alpha: 1) 32 | 33 | open var bgViewLeftImage: UIImage? 34 | open var bgViewRightImage: UIImage? 35 | 36 | fileprivate var _leftBackButton: UIButton? 37 | open var leftBackButton:UIButton? { 38 | if _leftBackButton == nil { 39 | _leftBackButton = UIButton(frame: CGRect(x: 0, y: 0, width: self.frame.height, height: self.frame.height)) 40 | _leftBackButton!.setImage(self.bgViewLeftImage, for: .normal) 41 | _leftBackButton!.addTarget(self, action: #selector(BWSwipeRevealCell.leftButtonTapped), for: .touchUpInside) 42 | _leftBackButton!.tintColor = UIColor.white 43 | _leftBackButton!.contentMode = .center 44 | self.backView!.addSubview(_leftBackButton!) 45 | } 46 | return _leftBackButton 47 | } 48 | 49 | fileprivate var _rightBackButton: UIButton? 50 | open var rightBackButton:UIButton? { 51 | if _rightBackButton == nil { 52 | _rightBackButton = UIButton(frame: CGRect(x: self.contentView.frame.maxX, y: 0, width: self.frame.height, height: self.frame.height)) 53 | _rightBackButton!.setImage(self.bgViewRightImage, for: .normal) 54 | _rightBackButton!.addTarget(self, action: #selector(BWSwipeRevealCell.rightButtonTapped), for: .touchUpInside) 55 | _rightBackButton!.tintColor = UIColor.white 56 | _rightBackButton!.contentMode = .center 57 | self.backView!.addSubview(_rightBackButton!) 58 | } 59 | return _rightBackButton 60 | } 61 | 62 | override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { 63 | super.init(style: .subtitle, reuseIdentifier: reuseIdentifier) 64 | let bgView: UIView = UIView(frame: self.frame) 65 | self.selectedBackgroundView = bgView 66 | } 67 | 68 | public required init?(coder aDecoder: NSCoder) { 69 | super.init(coder: aDecoder) 70 | let bgView: UIView = UIView(frame: self.frame) 71 | self.selectedBackgroundView = bgView 72 | } 73 | 74 | open override func prepareForReuse() { 75 | super.prepareForReuse() 76 | } 77 | 78 | open override func layoutSubviews() { 79 | super.layoutSubviews() 80 | } 81 | 82 | open override func cleanUp() { 83 | super.cleanUp() 84 | if self.shouldCleanUpBackView { 85 | _leftBackButton?.removeFromSuperview() 86 | _leftBackButton = nil 87 | _rightBackButton?.removeFromSuperview() 88 | _rightBackButton = nil 89 | _backView?.removeFromSuperview() 90 | _backView = nil 91 | } 92 | } 93 | 94 | open override func didStartSwiping() { 95 | super.didStartSwiping() 96 | self.backgroundView!.addSubview(self.backView!) 97 | } 98 | 99 | open override func animateContentViewForPoint(_ point: CGPoint) { 100 | super.animateContentViewForPoint(point) 101 | if point.x > 0 { 102 | let frame = self.leftBackButton!.frame 103 | let minX = getBackgroundViewImagesMaxX(point.x) 104 | let minY = frame.minY 105 | self.leftBackButton!.frame = CGRect(x: minX, y: minY, width: frame.width, height: frame.height) 106 | self.leftBackButton?.alpha = self.progress 107 | UIView.transition(with: _leftBackButton!, duration: 0.13, options: .transitionCrossDissolve, animations: { 108 | if point.x >= self.frame.height { 109 | self.backView?.backgroundColor = self.bgViewLeftColor 110 | } 111 | else { 112 | self.backView?.backgroundColor = self.bgViewInactiveColor 113 | } 114 | }, completion: nil) 115 | } else if point.x < 0 { 116 | let frame = self.rightBackButton!.frame 117 | let maxX = getBackgroundViewImagesMaxX(point.x) 118 | let minY = frame.minY 119 | self.rightBackButton!.frame = (CGRect(x: maxX, y: minY, width: frame.width, height: frame.height)) 120 | self.rightBackButton?.alpha = self.progress 121 | UIView.transition(with: _rightBackButton!, duration: 0.13, options: .transitionCrossDissolve, animations: { 122 | if -point.x >= self.frame.height { 123 | self.backView?.backgroundColor = self.bgViewRightColor 124 | } else { 125 | self.backView?.backgroundColor = self.bgViewInactiveColor 126 | } 127 | }, completion: nil) 128 | } 129 | } 130 | 131 | // MARK: - Reveal Cell Animations 132 | 133 | open override func animateCellSpringRelease() { 134 | super.animateCellSpringRelease() 135 | let pointX = self.contentView.frame.origin.x 136 | UIView.animate(withDuration: self.animationDuration, 137 | delay: 0, 138 | options: .curveLinear, 139 | animations: { 140 | if pointX > 0 { 141 | self.leftBackButton!.frame.origin.x = -self.threshold 142 | } else if pointX < 0 { 143 | self.rightBackButton!.frame.origin.x = self.frame.maxX 144 | } 145 | }, completion: nil) 146 | } 147 | 148 | open override func animateCellSwipeThrough() { 149 | super.animateCellSwipeThrough() 150 | let pointX = self.contentView.frame.origin.x 151 | UIView.animate(withDuration: self.animationDuration, 152 | delay: 0, 153 | options: .curveLinear, 154 | animations: { 155 | if pointX > 0 { 156 | self.leftBackButton!.frame.origin.x = self.frame.maxX 157 | } else if pointX < 0 { 158 | self.rightBackButton!.frame.origin.x = -self.threshold 159 | } 160 | }, completion: nil) 161 | } 162 | 163 | open override func animateCellSlidingDoor() { 164 | super.animateCellSlidingDoor() 165 | self.shouldCleanUpBackView = false 166 | } 167 | 168 | // MARK: - Reveal Cell 169 | 170 | open func getBackgroundViewImagesMaxX(_ x:CGFloat) -> CGFloat { 171 | if x > 0 { 172 | let frame = self.leftBackButton!.frame 173 | if self.type == .swipeThrough { 174 | return self.contentView.frame.origin.x - frame.width 175 | } else { 176 | return min(self.contentView.frame.minX - frame.width, 0) 177 | } 178 | } else { 179 | let frame = self.rightBackButton!.frame 180 | if self.type == .swipeThrough { 181 | return self.contentView.frame.maxX 182 | } else { 183 | return max(self.frame.maxX - frame.width, self.contentView.frame.maxX) 184 | } 185 | } 186 | } 187 | 188 | @objc open func leftButtonTapped () { 189 | self.shouldCleanUpBackView = true 190 | self.animateCellSpringRelease() 191 | let delegate = self.delegate as? BWSwipeRevealCellDelegate 192 | delegate?.swipeCellActivatedAction?(self, isActionLeft: true) 193 | } 194 | 195 | @objc open func rightButtonTapped () { 196 | self.shouldCleanUpBackView = true 197 | self.animateCellSpringRelease() 198 | let delegate = self.delegate as? BWSwipeRevealCellDelegate 199 | delegate?.swipeCellActivatedAction?(self, isActionLeft: false) 200 | } 201 | 202 | } 203 | -------------------------------------------------------------------------------- /BWSwipeRevealCell/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 | FMWK 17 | CFBundleShortVersionString 18 | 0.0.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(CURRENT_PROJECT_VERSION) 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /BWSwipeRevealCellExample/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // BWSwipeRevealCellExample 4 | // 5 | // Created by Kyle Newsome on 2015-11-13. 6 | // Copyright © 2015 Kyle Newsome. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import CoreData 11 | 12 | @UIApplicationMain 13 | class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDelegate { 14 | 15 | var window: UIWindow? 16 | 17 | 18 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 19 | // Override point for customization after application launch. 20 | let navigationController = self.window!.rootViewController as! UINavigationController 21 | let masterNavigationController = navigationController 22 | let controller = masterNavigationController.topViewController as! MasterViewController 23 | controller.managedObjectContext = self.managedObjectContext 24 | return true 25 | } 26 | 27 | func applicationWillResignActive(_ application: UIApplication) { 28 | // 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. 29 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 30 | } 31 | 32 | func applicationDidEnterBackground(_ application: UIApplication) { 33 | // 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. 34 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 35 | } 36 | 37 | func applicationWillEnterForeground(_ application: UIApplication) { 38 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 39 | } 40 | 41 | func applicationDidBecomeActive(_ application: UIApplication) { 42 | // 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. 43 | } 44 | 45 | func applicationWillTerminate(_ application: UIApplication) { 46 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 47 | // Saves changes in the application's managed object context before the application terminates. 48 | self.saveContext() 49 | } 50 | 51 | // MARK: - Core Data stack 52 | 53 | lazy var applicationDocumentsDirectory: URL = { 54 | // The directory the application uses to store the Core Data store file. This code uses a directory named "ca.bitwit.BWSwipeRevealCellExample" in the application's documents Application Support directory. 55 | let urls = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask) 56 | return urls[urls.count-1] 57 | }() 58 | 59 | lazy var managedObjectModel: NSManagedObjectModel = { 60 | // The managed object model for the application. This property is not optional. It is a fatal error for the application not to be able to find and load its model. 61 | let modelURL = Bundle.main.url(forResource: "BWSwipeRevealCellExample", withExtension: "momd")! 62 | return NSManagedObjectModel(contentsOf: modelURL)! 63 | }() 64 | 65 | lazy var persistentStoreCoordinator: NSPersistentStoreCoordinator = { 66 | // The persistent store coordinator for the application. This implementation creates and returns a coordinator, having added the store for the application to it. This property is optional since there are legitimate error conditions that could cause the creation of the store to fail. 67 | // Create the coordinator and store 68 | let coordinator = NSPersistentStoreCoordinator(managedObjectModel: self.managedObjectModel) 69 | let url = self.applicationDocumentsDirectory.appendingPathComponent("SingleViewCoreData.sqlite") 70 | var failureReason = "There was an error creating or loading the application's saved data." 71 | do { 72 | try coordinator.addPersistentStore(ofType: NSSQLiteStoreType, configurationName: nil, at: url, options: nil) 73 | } catch { 74 | // Report any error we got. 75 | var dict = [String: AnyObject]() 76 | dict[NSLocalizedDescriptionKey] = "Failed to initialize the application's saved data" as AnyObject? 77 | dict[NSLocalizedFailureReasonErrorKey] = failureReason as AnyObject? 78 | 79 | dict[NSUnderlyingErrorKey] = error as NSError 80 | let wrappedError = NSError(domain: "YOUR_ERROR_DOMAIN", code: 9999, userInfo: dict) 81 | // Replace this with code to handle the error appropriately. 82 | // abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development. 83 | NSLog("Unresolved error \(wrappedError), \(wrappedError.userInfo)") 84 | abort() 85 | } 86 | 87 | return coordinator 88 | }() 89 | 90 | lazy var managedObjectContext: NSManagedObjectContext = { 91 | // Returns the managed object context for the application (which is already bound to the persistent store coordinator for the application.) This property is optional since there are legitimate error conditions that could cause the creation of the context to fail. 92 | let coordinator = self.persistentStoreCoordinator 93 | var managedObjectContext = NSManagedObjectContext(concurrencyType: .mainQueueConcurrencyType) 94 | managedObjectContext.persistentStoreCoordinator = coordinator 95 | return managedObjectContext 96 | }() 97 | 98 | // MARK: - Core Data Saving support 99 | 100 | func saveContext () { 101 | if managedObjectContext.hasChanges { 102 | do { 103 | try managedObjectContext.save() 104 | } catch { 105 | // Replace this implementation with code to handle the error appropriately. 106 | // abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development. 107 | let nserror = error as NSError 108 | NSLog("Unresolved error \(nserror), \(nserror.userInfo)") 109 | abort() 110 | } 111 | } 112 | } 113 | 114 | } 115 | 116 | -------------------------------------------------------------------------------- /BWSwipeRevealCellExample/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 | } -------------------------------------------------------------------------------- /BWSwipeRevealCellExample/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /BWSwipeRevealCellExample/Assets.xcassets/Delete.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "delete-md.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "delete-md-@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /BWSwipeRevealCellExample/Assets.xcassets/Delete.imageset/delete-md-@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitwit/BWSwipeRevealCell/8711166a9405713cd0036a876cc67cf4b61c26f2/BWSwipeRevealCellExample/Assets.xcassets/Delete.imageset/delete-md-@2x.png -------------------------------------------------------------------------------- /BWSwipeRevealCellExample/Assets.xcassets/Delete.imageset/delete-md.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitwit/BWSwipeRevealCell/8711166a9405713cd0036a876cc67cf4b61c26f2/BWSwipeRevealCellExample/Assets.xcassets/Delete.imageset/delete-md.png -------------------------------------------------------------------------------- /BWSwipeRevealCellExample/Assets.xcassets/Done.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "check-md.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "check-md-@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /BWSwipeRevealCellExample/Assets.xcassets/Done.imageset/check-md-@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitwit/BWSwipeRevealCell/8711166a9405713cd0036a876cc67cf4b61c26f2/BWSwipeRevealCellExample/Assets.xcassets/Done.imageset/check-md-@2x.png -------------------------------------------------------------------------------- /BWSwipeRevealCellExample/Assets.xcassets/Done.imageset/check-md.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitwit/BWSwipeRevealCell/8711166a9405713cd0036a876cc67cf4b61c26f2/BWSwipeRevealCellExample/Assets.xcassets/Done.imageset/check-md.png -------------------------------------------------------------------------------- /BWSwipeRevealCellExample/BWSwipeRevealCellExample.xcdatamodeld/.xccurrentversion: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | _XCCurrentVersionName 6 | BWSwipeRevealCellExample.xcdatamodel 7 | 8 | 9 | -------------------------------------------------------------------------------- /BWSwipeRevealCellExample/BWSwipeRevealCellExample.xcdatamodeld/BWSwipeRevealCellExample.xcdatamodel/contents: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /BWSwipeRevealCellExample/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 | -------------------------------------------------------------------------------- /BWSwipeRevealCellExample/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 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /BWSwipeRevealCellExample/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 | 2.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UIStatusBarTintParameters 34 | 35 | UINavigationBar 36 | 37 | Style 38 | UIBarStyleDefault 39 | Translucent 40 | 41 | 42 | 43 | UISupportedInterfaceOrientations 44 | 45 | UIInterfaceOrientationPortrait 46 | UIInterfaceOrientationLandscapeLeft 47 | UIInterfaceOrientationLandscapeRight 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /BWSwipeRevealCellExample/MasterViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MasterViewController.swift 3 | // BWSwipeTableCellExample 4 | // 5 | // Created by Kyle Newsome on 2015-11-12. 6 | // Copyright © 2015 Kyle Newsome. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import CoreData 11 | import BWSwipeRevealCell 12 | 13 | class MasterViewController: UITableViewController, NSFetchedResultsControllerDelegate, BWSwipeRevealCellDelegate { 14 | 15 | var managedObjectContext: NSManagedObjectContext? = nil 16 | 17 | override func viewDidLoad() { 18 | super.viewDidLoad() 19 | let addButton = UIBarButtonItem(barButtonSystemItem: .add, target: self, action: #selector(MasterViewController.insertNewObject(_:))) 20 | self.navigationItem.rightBarButtonItem = addButton 21 | } 22 | 23 | @objc func insertNewObject(_ sender: AnyObject) { 24 | let context = self.fetchedResultsController.managedObjectContext 25 | let entity = self.fetchedResultsController.fetchRequest.entity! 26 | 27 | //Create one of each type 28 | for i in 0..<3 { 29 | let newManagedObject = NSEntityDescription.insertNewObject(forEntityName: entity.name!, into: context) 30 | newManagedObject.setValue(i, forKey: "type") 31 | } 32 | 33 | do { 34 | try context.save() 35 | } catch { 36 | abort() 37 | } 38 | } 39 | 40 | func removeObjectAtIndexPath(_ indexPath:IndexPath) { 41 | let context = self.fetchedResultsController.managedObjectContext 42 | //Deleting objects regardless of done/delete for the purpose of this example 43 | context.delete(self.fetchedResultsController.object(at: indexPath)) 44 | do { 45 | try context.save() 46 | } catch { 47 | abort() 48 | } 49 | } 50 | 51 | // MARK: - Table View 52 | 53 | override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { 54 | return 72 55 | } 56 | 57 | override func numberOfSections(in tableView: UITableView) -> Int { 58 | return self.fetchedResultsController.sections?.count ?? 0 59 | } 60 | 61 | override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 62 | let sectionInfo = self.fetchedResultsController.sections![section] 63 | return sectionInfo.numberOfObjects 64 | } 65 | 66 | override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 67 | let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) 68 | self.configureCell(cell, atIndexPath: indexPath) 69 | return cell 70 | } 71 | 72 | func configureCell(_ cell: UITableViewCell, atIndexPath indexPath: IndexPath) { 73 | let object = self.fetchedResultsController.object(at: indexPath) 74 | let swipeCell:BWSwipeRevealCell = cell as! BWSwipeRevealCell 75 | 76 | swipeCell.bgViewLeftImage = UIImage(named:"Done")!.withRenderingMode(.alwaysTemplate) 77 | swipeCell.bgViewLeftColor = UIColor.green 78 | 79 | swipeCell.bgViewRightImage = UIImage(named:"Delete")!.withRenderingMode(.alwaysTemplate) 80 | swipeCell.bgViewRightColor = UIColor.red 81 | 82 | let type = BWSwipeCellType(rawValue: object.value(forKey: "type") as! Int)! 83 | swipeCell.type = type 84 | 85 | switch type { 86 | case .swipeThrough: 87 | swipeCell.textLabel!.text = "Swipe Through" 88 | break 89 | case .springRelease: 90 | swipeCell.textLabel!.text = "Spring Release" 91 | break 92 | case .slidingDoor: 93 | swipeCell.textLabel!.text = "Sliding Door" 94 | break 95 | } 96 | 97 | swipeCell.delegate = self 98 | } 99 | 100 | // MARK: - Fetched results controller 101 | 102 | var fetchedResultsController: NSFetchedResultsController { 103 | if _fetchedResultsController != nil { 104 | return _fetchedResultsController! 105 | } 106 | 107 | let fetchRequest:NSFetchRequest = NSFetchRequest() 108 | let entity = NSEntityDescription.entity(forEntityName: "Event", in: self.managedObjectContext!) 109 | fetchRequest.entity = entity 110 | fetchRequest.fetchBatchSize = 20 111 | let sortDescriptor = NSSortDescriptor(key: "type", ascending: false) 112 | fetchRequest.sortDescriptors = [sortDescriptor] 113 | let aFetchedResultsController = NSFetchedResultsController(fetchRequest: fetchRequest, managedObjectContext: self.managedObjectContext!, sectionNameKeyPath: nil, cacheName: "Master") 114 | aFetchedResultsController.delegate = self 115 | _fetchedResultsController = aFetchedResultsController 116 | 117 | do { 118 | try _fetchedResultsController!.performFetch() 119 | } catch { 120 | abort() 121 | } 122 | 123 | return _fetchedResultsController! 124 | } 125 | var _fetchedResultsController: NSFetchedResultsController? = nil 126 | 127 | func controllerWillChangeContent(_ controller: NSFetchedResultsController) { 128 | self.tableView.beginUpdates() 129 | } 130 | 131 | func controller(_ controller: NSFetchedResultsController, didChange sectionInfo: NSFetchedResultsSectionInfo, atSectionIndex sectionIndex: Int, for type: NSFetchedResultsChangeType) { 132 | switch type { 133 | case .insert: 134 | self.tableView.insertSections(IndexSet(integer: sectionIndex), with: .fade) 135 | case .delete: 136 | self.tableView.deleteSections(IndexSet(integer: sectionIndex), with: .fade) 137 | default: 138 | return 139 | } 140 | } 141 | 142 | func controller(_ controller: NSFetchedResultsController, didChange anObject: Any, at indexPath: IndexPath?, for type: NSFetchedResultsChangeType, newIndexPath: IndexPath?) { 143 | switch type { 144 | case .insert: 145 | tableView.insertRows(at: [newIndexPath!], with: .fade) 146 | case .delete: 147 | tableView.deleteRows(at: [indexPath!], with: .fade) 148 | case .update: 149 | self.configureCell(tableView.cellForRow(at: indexPath!)!, atIndexPath: indexPath!) 150 | case .move: 151 | tableView.deleteRows(at: [indexPath!], with: .fade) 152 | tableView.insertRows(at: [newIndexPath!], with: .fade) 153 | @unknown default: 154 | assertionFailure() 155 | } 156 | } 157 | 158 | func controllerDidChangeContent(_ controller: NSFetchedResultsController) { 159 | self.tableView.endUpdates() 160 | } 161 | 162 | // MARK: - Reveal Cell Delegate 163 | 164 | func swipeCellWillRelease(_ cell: BWSwipeCell) { 165 | print("Swipe Cell Will Release") 166 | if cell.state != .normal && cell.type != .slidingDoor { 167 | let indexPath: IndexPath = tableView.indexPath(for: cell)! 168 | self.removeObjectAtIndexPath(indexPath) 169 | } 170 | } 171 | 172 | func swipeCellActivatedAction(_ cell: BWSwipeCell, isActionLeft: Bool) { 173 | print("Swipe Cell Activated Action") 174 | let indexPath: IndexPath = tableView.indexPath(for: cell)! 175 | self.removeObjectAtIndexPath(indexPath) 176 | } 177 | 178 | func swipeCellDidChangeState(_ cell: BWSwipeCell) { 179 | print("Swipe Cell Did Change State") 180 | if cell.state != .normal { 181 | print("-> Cell Passed Threshold") 182 | } else { 183 | print("-> Cell Returned to Normal") 184 | } 185 | } 186 | 187 | func swipeCellDidCompleteRelease(_ cell: BWSwipeCell) { 188 | print("Swipe Cell Did Complete Release") 189 | } 190 | 191 | func swipeCellDidSwipe(_ cell: BWSwipeCell) { 192 | print("Swipe Cell Did Swipe") 193 | } 194 | 195 | func swipeCellDidStartSwiping(_ cell: BWSwipeCell) { 196 | print("Swipe Cell Did Start Swiping") 197 | } 198 | 199 | } 200 | 201 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Kyle Newsome 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 | 2 | # BWSwipeRevealCell 3 | 4 | ![Example](https://raw.githubusercontent.com/bitwit/BWSwipeRevealCell/master/example.gif) 5 | 6 | ### Using the library 7 | 8 | **Note: Use version 1.0.1 for Swift 2.3 support and version 2.0.0 or higher for Swift 3 support ** 9 | 10 | There are two main classes available - `BWSwipeCell` and `BWSwipeRevealCell` 11 | 12 | **BWSwipeCell** - Only contains the pan gesture handling, and is useful mainly for heavy customization through subclassing if all you need is a leg up on swipe interactions 13 | 14 | **BWSwipeRevealCell** - Is an out of the box solution that lets you set images and colors for 1 action on the left and right of the table cell. BWSwipeRevealCell is a subclass of BWSwipeCell. 15 | 16 | 17 | ### BWSwipeRevealCell Example 18 | After setting `BWSwipeRevealCell` as your table cell's type in the storyboard and setting a delegate. Use this code in your controller: 19 | ```swift 20 | 21 | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 22 | let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as! BWSwipeRevealCell 23 | 24 | swipeCell.bgViewLeftImage = UIImage(named:"Done")!.withRenderingMode(.alwaysTemplate) 25 | swipeCell.bgViewLeftColor = UIColor.green 26 | 27 | swipeCell.bgViewRightImage = UIImage(named:"Delete")!.withRenderingMode(.alwaysTemplate) 28 | swipeCell.bgViewRightColor = UIColor.red 29 | 30 | swipeCell.type = .springRelease 31 | 32 | swipeCell.delegate = self // Or whatever your delegate might be 33 | return cell 34 | } 35 | ``` 36 | 37 | ### Customizing through the interface 38 | 39 | #### BWSwipeCell Properties 40 | 41 | **var type:BWSwipeCellType** 42 | 43 | Can be `.springRelease`, `.swipeThrough` or `.slidingDoor`. Defaults to `.springRelease` 44 | 45 | **var revealDirection: BWSwipeCellRevealDirection** 46 | 47 | Can be `.both`, `.left` or `.right`. Defaults to `.both` 48 | 49 | **(readonly) var state: BWSwipeCellState** 50 | 51 | Can be `.normal`, `.pastThresholdLeft` or `.pastThresholdRight` 52 | 53 | **var threshold: CGFloat** 54 | 55 | The point at which pan elasticity starts, and `state` changes. Defaults to the height of the `UITableViewCell` (i.e. when it form a perfect square) 56 | 57 | **(readonly) var progress:CGFloat** 58 | 59 | A number between 0 and 1 to indicate progress toward reaching threshold in the current swiping direction. Useful for changing UI gradually as the user swipes. 60 | 61 | **var shouldExceedThreshold: Bool** 62 | 63 | Control whether or not the cell pans past the threshold point 64 | 65 | **var panElasticityFactor: CGFloat** 66 | 67 | Control how much elasticity there is past threshold, if it can be exceeded. Default is `0.7` and `1.0` would mean no elastic resistance 68 | 69 | **var animationDuration: Double** 70 | 71 | Animation duration. Defaults to `0.2` 72 | 73 | **weak var delegate: BWSwipeCellDelegate?** 74 | 75 | Set the delegate on the cell 76 | 77 | ```swift 78 | @objc public protocol BWSwipeCellDelegate: NSObjectProtocol { 79 | optional func swipeCellDidStartSwiping(cell: BWSwipeCell) 80 | optional func swipeCellDidSwipe(cell: BWSwipeCell) 81 | optional func swipeCellWillRelease(cell: BWSwipeCell) 82 | optional func swipeCellDidCompleteRelease(cell: BWSwipeCell) 83 | optional func swipeCellDidChangeState(cell: BWSwipeCell) 84 | } 85 | ``` 86 | 87 | #### BWSwipeRevealCell Properties 88 | 89 | **var bgViewInactiveColor: UIColor** 90 | 91 | **var bgViewLeftColor: UIColor** 92 | 93 | **var bgViewRightColor: UIColor** 94 | 95 | Colors for inactive, and activated states for left and right 96 | 97 | **var bgViewLeftImage: UIImage?** 98 | 99 | **var bgViewRightImage: UIImage?** 100 | 101 | Images for the left and right actions 102 | 103 | **weak var delegate: BWSwipeRevealCellDelegate?** 104 | 105 | ```swift 106 | @objc public protocol BWSwipeRevealCellDelegate:BWSwipeCellDelegate { 107 | optional func swipeCellActivatedAction(cell: BWSwipeCell, isActionLeft: Bool) 108 | } 109 | ``` 110 | 111 | Set the delegate on the cell 112 | ### Roadmap 113 | Some brief ideas on ways to improve this library 114 | 115 | #### v 1.x.0 (Swift 2.x version) 116 | - Complete 117 | 118 | ##### v 2.x.0 (Swift 3.x version) 119 | - Fix bugs 120 | 121 | ##### v 3.0.0 122 | - [See Github Milestone](https://github.com/bitwit/BWSwipeRevealCell/milestones/Version%203.0.0) 123 | 124 | ##### v x.0.0 (a.k.a. Ideas. PRs welcome.) 125 | - Customizable interaction per side (i.e. left .SwipeThrough, right .SlidingDoor) 126 | - Possible subclass for allowing .SlidingDoor to convert to .SwipeThrough past a threshold point (see Mail.app) 127 | -------------------------------------------------------------------------------- /example.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitwit/BWSwipeRevealCell/8711166a9405713cd0036a876cc67cf4b61c26f2/example.gif --------------------------------------------------------------------------------