TestsTested | ✓ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Jan 2017 |
Maintained by Mateusz Fidos.
To run the example project, clone the repo, open and run Example scheme.
ARC
iOS9
MFRevealCell is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "MFRevealCell"
Start with some importing:
import MFRevealCell
Usage: Register cell class (there is a tableView extension created for this) by calling:
tableView.registerCell(ofType: WLRevealTableViewCell.self)
you can do it like so:
@IBOutlet var tableView: UITableView! {
didSet {
tableView.registerCell(ofType: WLRevealTableViewCell.self)
}
}
Be sure to provide proper data source!
Create reveal option items that you wan't to use in your cell. You can use one of the defined types with default images/titles or create items with your custom background color, title and image. (if those custom values are nil, default framework values will be passed instead!)
Configure your cell inside method:
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueCell(ofType: WLRevealTableViewCell.self)
let user = items[indexPath.row]
cell.titleLabel.text = user.name
cell.subtitleLabel.text = user.sureName
let delete = WLRevealOptionItem(type: .delete)
let share = WLRevealOptionItem(type: .share)
let edit = WLRevealOptionItem(type: .edit)
cell.configureWith(delegate: self, items: [delete, share, edit])
return cell
}
Be sure to register your view controller to be MFRevealCell delegate to receive callbacks when options close/open and action was pressed
Example on how to handle reseting previous edited cell state:
func didOpen(cell: WLRevealTableViewCell) {
print("did open cell options")
guard let previousEditedCell = editingCell else {
editingCell = cell
return
}
if (previousEditedCell != cell) {
editingCell = cell
previousEditedCell.closeCell()
}
}
Mateusz Fidos, [email protected]
MFRevealCell is available under the MIT license. See the LICENSE file for more info.