StickyCells
允许设置多个级别的粘性单元格
用法
import StickyCells
您必须使用 StickyCellsTableView
,并从 StickyCellWith<StickyView: UIView>
继承单元格类,其中 StickyView
是将要在表格中显示的实际视图
class MyStickyCell: StickyCellWith<Label> {}
然后,在 dequeueReusableCell(withIdentifier identifier: String, for indexPath: IndexPath) -> UITableViewCell
方法中,在粘性单元格上调用 setLevel(_ level: Int?)
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: reuseIdentifier, for: indexPath)
if let stickyCell = cell as? MyStickyCell {
stickyCell.stickyView.text = "I'm a sticky cell"
stickyCell.setLevel(0)
}
return cell
}
有关详细信息,请查看 示例应用的源代码
安装
target 'YOUR_TARGET' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
pod 'StickyCells'
end