Open
Description
Can this be added as a TableViewCell? If so can you add an example to do that? I am not able to make it work
This is my TableViewCell
//
// SwipeableCardTableViewCell.swift
// Hunbun
//
// Created by noor on 05/01/24.
//
import UIKit
import ZLSwipeableViewSwift
class SwipeableCardTableViewCell: UITableViewCell {
var swipeableView: ZLSwipeableView!
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
setup()
}
required init?(coder: NSCoder) {
super.init(coder: coder)
setup()
}
func setup() {
backgroundColor = .clear
contentView.backgroundColor = .clear
configureSwipeableView()
layoutSwipeableView()
}
func configureSwipeableView() {
swipeableView = ZLSwipeableView()
swipeableView.translatesAutoresizingMaskIntoConstraints = false
contentView.addSubview(swipeableView)
swipeableView.didStart = { _, _ in
print("Did start swiping view")
}
swipeableView.nextView = { [weak self] in
return self?.nextCardView()
}
swipeableView.didEnd = { _, location in
print("Did end swiping view at location: \(location)")
}
swipeableView.didSwipe = { _, direction, vector in
print("Did swipe view in direction: \(direction), vector: \(vector)")
}
swipeableView.didCancel = { _ in
print("Did cancel swiping view")
}
swipeableView.didTap = { _, location in
print("Did tap at location \(location)")
}
swipeableView.didDisappear = { _ in
print("Did disappear swiping view")
}
}
func layoutSwipeableView() {
swipeableView.anchor(top:contentView.topAnchor, left: contentView.leftAnchor, bottom: contentView.bottomAnchor, right: contentView.rightAnchor)
}
func nextCardView() -> UIView? {
// Implement your logic to create the next card view
// Example:
let cardView = UIView(frame: swipeableView.bounds)
cardView.backgroundColor = .blue
return cardView
}
}
Metadata
Metadata
Assignees
Labels
No labels