Introduction
Welcome to the documentation of the RHPreviewCell library! RHPreviewCell is a lightweight library that allows you to add a preview feature to your table view cells, similar to the Peek and Pop functionality introduced in iOS 9.
Installation
To install RHPreviewCell using CocoaPods, add the following line to your Podfile:
pod 'RHPreviewCell'
Alternatively, you can manually include the RHPreviewCell files in your project.
Usage
Importing
Import the RHPreviewCell header file in your view controller:
import RHPreviewCell
Initializing
To use RHPreviewCell, create an instance of RHPreviewTableViewCell in your table view data source method:
let previewCell = RHPreviewTableViewCell(style: .default, reuseIdentifier: "previewCell")
Customization
RHPreviewTableViewCell provides various methods to customize the preview behavior:
1. Set Preview Properties
You can set the properties of the preview cell using the following methods:
previewCell.previewActionTitle = "Preview"
previewCell.previewActionEnabled = true
previewCell.contentView.backgroundColor = .white
2. Implement Delegate Methods
You can implement delegate methods to handle preview cell events. Conform to the RHPreviewTableViewCellDelegate protocol in your view controller and implement the following methods:
func previewCellDidBeginPreview(_ cell: RHPreviewTableViewCell)
func previewCellDidEndPreview(_ cell: RHPreviewTableViewCell)
3. Enable/Disable Previewing
You can enable or disable previewing for a particular cell using the following method:
previewCell.enablePreview = true // or false
Demo
Find a demo project demonstrating the usage of RHPreviewCell at: https://github.com/robertherdzik/RHPreviewCell
Conclusion
Congratulations! You have successfully set up and customized the RHPreviewCell library in your project. Enjoy using the preview feature in your table view cells!