swift 自定义侧滑删除

Related tags

Utility SweptCell
Overview

SweptCell

SweptCell 一款swift版本的tableViewCell的侧滑删除的控件 有两种侧滑模式 第一种是普通的侧滑 第二种是带有提醒模式的侧滑

Requirements

  • Swift 5.0+

Usage

pod 'SweptCell', :git => 'https://github.com/CunningTturtle/SweptCell.git'

import SweptCell

1 继承 WLTableViewCell

    class CustomCell: WLTableViewCell {
         xxx 自己的东西
    }

2 遵守WLTableViewCellDelegate协议

     class ViewController: UIViewController,WLTableViewCellDelegate {
     }
     
3 设置代理

    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "CustomCell")
            as! CustomCell
        cell.delegate = self
        return cell
    }
    
4 实现 func willLeftSliding() -> [WLSweptItemModel] 方法

//普通侧滑 这里可以返回值是一个数组可以返回多个item
func willLeftSliding() -> [WLSweptItemModel] {
    
    let model = WLSweptItemModel.init()
    model.willClose = { canClose in
        //当任务结束后 将该值赋值为true 即可关闭 侧滑 
        //点击的回调
        canClose = true
    }
    //自定义视图 建议用snp进行约束 
    model.contentView.addSubview(contentView())
    model.contentView.backgroundColor = .red
    return [model]
}

//带有提醒模式的侧滑 这里可以返回值是一个数组可以返回多个item
func willLeftSliding() -> [WLSweptItemModel] {

    let modelAlert = WLSweptItemModel.init()
    modelAlert.itemType = .alert
    //自定义视图 建议用snp进行约束 
    modelAlert.contentView.addSubview(contentView())

    modelAlert.willClose = { canClose in
        //当任务结束后 将该值赋值为true 即可关闭 侧滑
        //点击的回调
        canClose = true
    }
    modelAlert.willAlert = { manager in
        //在此处可以修改第二阶段的要展示的UI
        //点击的回调
        if let subView = manager.subviews.first as? UILabel {
            subView.text = "333"
        }
    }
    modelAlert.contentView.backgroundColor = .yellow

    return [modelAlert]
}
    
## 如果需要刷新item数据 请reloadCell 或者 reloadTableView
Owner
冬瓜皮
冬瓜皮
A tiny generator of random data for swift

SwiftRandom SwiftRandom is a tiny help suite for generating random data such as Random human stuff like: names, gender, titles, tags, conversations Ra

Kan Yilmaz 558 Nov 23, 2021
Random data generation in Swift

RandomKit is a Swift framework that makes random data generation simple and easy. Build Status Installation Compatibility Swift Package Manager CocoaP

Nikolai Vazquez 1.5k Nov 20, 2021
:smirk: How Swift standard types and classes were supposed to work.

EZSwiftExtensions How Swift standard types and classes were supposed to work. A collection of useful extensions for the Swift Standard Library, Founda

Goktug Yilmaz 2.9k Dec 4, 2021
The missing light persistence layer for Swift

If you're planning on using Swift 4 in the near future, please consider using the new Codable protocols which provide the same functionality as Pantry

Nick O'Neill 845 Nov 4, 2021
A parser combinator library written in the Swift programming language.

SwiftParsec SwiftParsec is a Swift port of the Parsec parser combinator library. It allows the creation of sophisticated parsers from a set of simple

David Dufresne 206 Nov 6, 2021
A Swift collection of unique, ordered objects

Introduction OrderedSet is essentially the Swift equivalent of Foundation's NSOrderedSet/NSMutableOrderedSet. It was created so Swift would have a uni

Weebly 247 Nov 6, 2021
📆 Breeze through Date, DateComponents, and TimeInterval with Swift!

Datez ?? Breeze through Date, DateComponents, and TimeInterval Highlights Two Custom Structs Only (value types FTW!): DateView: An Date associated wit

Kitz 258 Aug 4, 2021
BFKit-Swift is a collection of useful classes, structs and extensions to develop Apps faster.

Features • Classes and Extensions Compatibility • Requirements • Communication • Contributing • Installing and Usage • Documentation • Changelog • Exa

Fabrizio Brancati 986 Nov 18, 2021
:flags: Unit converter in Swift

Scale ❤️ Support my app ❤️ Push Hero - pure Swift native macOS application to test push notifications PastePal - Pasteboard, note and shortcut manager

Khoa 326 Sep 25, 2021
✨ Super sweet syntactic sugar for Swift initializers

Then ✨ Super sweet syntactic sugar for Swift initializers. At a Glance Initialize UILabel then set its properties. let label = UILabel().then { $0.t

Suyeol Jeon 3.6k Dec 3, 2021
📡 Helping you own NotificationCenter in Swift!

Notificationz ?? Helping you own NotificationCenter Highlights Keep Your Naming Conventions: This library gives you convenient access to NotificationC

Kitz 75 Nov 27, 2021
DeviceGuru is a simple lib (Swift) to know the exact type of the device, e.g. iPhone 6 or iPhone 6s. Please ⭐️ this repo on the top right corner to make this repo popular.

DeviceGuru DeviceGuru is a simple lib (Swift) to know the exact type of the device, e.g. iPhone 6 or iPhone 6s Easy to use Light weight From version 5

Inder Kumar 415 Nov 23, 2021
Simple and Lightweight App Version Tracking for iOS written in Swift

AEAppVersion Simple and lightweight iOS App Version Tracking written in Swift I made this for personal use, but feel free to use it or contribute. For

Marko Tadić 12 Nov 16, 2021
A Swift μ-Library for Somewhat Dependent Types

Validated Validated is a μ-library (~50 Source Lines of Code) that allows you make better use of Swift's type system by providing tools for easily gen

Benjamin Encz 608 Nov 8, 2021
Extensions for Swift Standard Types and Classes

Cent Cent is a library that extends certain Swift object types using the extension feature and gives its two cents to Swift language. Dollar is a Swif

Ankur Patel 221 Aug 7, 2021
Easy way to detect iOS device properties, OS versions and work with screen sizes. Powered by Swift.

Easy way to detect device environment: Device model and version Screen resolution Interface orientation iOS version Battery state Environment Helps to

Anatoliy Voropay 578 Nov 23, 2021
Preview extractor for news, articles and full-texts in Swift

ReadabilityKit Preview extractor for news, articles and full-texts in Swift We are a development agency building phenomenal apps. Features Extracts: T

Exyte 765 Nov 15, 2021
Super powerful remote config utility written in Swift (iOS, watchOS, tvOS, OSX)

Mission Control Super powerful remote config utility written in Swift (iOS, watchOS, tvOS, OSX) Brought to you by Have you ever wished you could chang

appculture 112 Nov 8, 2021
Useful functions and extensions for sorting in Swift

SwiftSortUtils Motivation This library takes a shot at making sorting in Swift more pleasant. It also allows you to reuse your old NSSortDescriptor in

Daniel Strittmatter 58 Oct 28, 2021