iOS开源-SwipeCellKit:UITableViewCell 内各种滑动变化及动画效果
Jolene71D
8年前
<h2>SwipeCellKit</h2> <p>Swipeable UITableViewCell based on the stock Mail.app, implemented in Swift.</p> <p><img src="https://simg.open-open.com/show/3e8168b9c2e5bf47a83635cb2d154935.gif"></p> <h2>About</h2> <p>A swipeable UITableViewCell with support for:</p> <ul> <li>Left and right swipe actions</li> <li>Action buttons with: <em>text only, text + image, image only</em></li> <li>Haptic Feedback</li> <li>Customizable transitions: <em>Border, Drag, and Reveal</em></li> <li>Animated expansion when dragging past threshold</li> </ul> <h2>Demo</h2> <h3>Transition Styles</h3> <p>The transition style describes how the action buttons are exposed during the swipe.</p> <p>Border</p> <p><img src="https://simg.open-open.com/show/16a663db580e28378035451c3d9cada3.gif"></p> <p>Drag</p> <p><img src="https://simg.open-open.com/show/0fe300a345253ed12de2604e5b6d0f09.gif"></p> <p>Reveal</p> <p><img src="https://simg.open-open.com/show/fd5f27a78141e01814218fd81e9ecd49.gif"></p> <h3>Expansion Styles</h3> <p>The expansion style describes the behavior when the cell is swiped past a defined threshold.</p> <p>None</p> <p><img src="https://simg.open-open.com/show/71f15ed594cf4037a57293e42a795e1d.gif"></p> <p>Selection</p> <p><img src="https://simg.open-open.com/show/aff92521cab5bc2b52def9036e119123.gif"></p> <p>Destructive</p> <p><img src="https://simg.open-open.com/show/7fad3bec4dc652612d60b9e5ec53809b.gif"></p> <h2>Requirements</h2> <ul> <li>Swift 3.0</li> <li>Xcode 8</li> <li>iOS 10.0+</li> </ul> <h2>Installation</h2> <p><a href="/misc/goto?guid=4958869288453138992" rel="nofollow,noindex">CocoaPods</a> (recommended)</p> <pre> use_frameworks! # Latest release in CocoaPods pod 'SwipeCellKit' # Get the latest on develop pod 'SwipeCellKit', :git => 'https://github.com/jerkoch/SwipeCellKit.git', :branch => 'develop'</pre> <p><a href="/misc/goto?guid=4958877729065386929" rel="nofollow,noindex">Carthage</a></p> <pre> github "jerkoch/SwipeCellKit"</pre> <h2>Documentation</h2> <p>Read the <a href="/misc/goto?guid=4959738196440348938" rel="nofollow,noindex">docs</a> . Generated with <a href="/misc/goto?guid=4958999206733718621" rel="nofollow,noindex">jazzy</a> . Hosted by <a href="/misc/goto?guid=4959639316179996865" rel="nofollow,noindex">GitHub Pages</a> .</p> <h2>Usage</h2> <p>Set the delegate property on SwipeTableViewCell :</p> <pre> override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "Cell") as! SwipeTableViewCell cell.delegate = self return cell }</pre> <p>Adopt the SwipeTableViewCellDelegate protocol:</p> <pre> func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath, for orientation: SwipeActionsOrientation) -> [SwipeAction]? { guard orientation == .right else { return nil } let deleteAction = SwipeAction(style: .destructive, title: "Delete") { action, indexPath in // handle action by updating model with deletion } // customize the action appearance deleteAction.image = UIImage(named: "delete") return [deleteAction] }</pre> <p>Optionally, you call implement the options method to customize the behavior of the swipe actions:</p> <pre> func tableView(_ tableView: UITableView, editActionsOptionsForRowAt indexPath: IndexPath, for orientation: SwipeActionsOrientation) -> SwipeTableOptions { var options = SwipeTableOptions() options.expansionStyle = .destructive options.transitionStyle = .border return options }</pre> <h2>Credits</h2> <p>Created and maintained by <a href="/misc/goto?guid=4959738196607811898" rel="nofollow,noindex"> <strong>@jerkoch</strong> </a> .</p> <h2>License</h2> <p>SwipeCellKit is released under an <a href="/misc/goto?guid=4958849120936875745" rel="nofollow,noindex">MIT License</a> . See LICENSE for details.</p> <p>Please provide attribution, it is greatly appreciated.</p> <p> </p>