LNParallaxTVCell 1.0.0

LNParallaxTVCell 1.0.0

Lanars 管理。



  • Lanars

LNParallaxTVCell - Swift

iOS Platform Swift 5.0 License

UITableViewCell 的子类,用于展示视差效果。您不需要使用 UITableViewDelegate 或其他东西,可以像使用 UITableViewCell 一样使用它,也可以自定义视差比例或其他属性。

Preview

安装

要通过 CocoaPods 安装,请将以下行添加到 Podfile 中

pod 'LNParallaxTVCell'

在应用中手动安装 LNParallaxTVCell,只需将 LNParallaxTVCell.swift 类拖放到项目中即可

使用方法

  1. 将 LNParallaxTVCell 模块导入到您的类中
import LNParallaxTVCell
  1. 在故事板或 .xib 文件中将您的 UITableViewCell 类设置为 LNParallaxTVCell

  2. 将您的图像设置为 "parallaxImage" 以显示

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    guard let cell = tableView.dequeueReusableCell(withIdentifier: "cellIdentifier") as? LNParallaxTVCell else {
        return UITableViewCell()
    }
        
    cell.parallaxImage.image = UIImage(named: "myImage")      
    
    return cell
}
  1. 可选 - 您可以将 parralaxRatio 从 0.0 修改到 1.0(默认值为 0.5)
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    guard let cell = tableView.dequeueReusableCell(withIdentifier: "cellIdentifier") as? LNParallaxTVCell else {
        return UITableViewCell()
    }
        
    cell.parallaxImage.image = UIImage(named: "myImage")
    cell.parallaxRatio = 1.0
        
    return cell
}

还可以查看一个包含视差表格视图单元格的示例项目

许可证

版权所有 © 2019 Lanars

https://lanars.com

本软件由版权所有者和贡献者提供,"按现状"提供,并且不提供任何明示或暗示的保证,包括但不限于对适销性和针对特定用途的适用性的暗示保证。在任何情况下,版权所有者或贡献者不应对任何直接、间接、偶然、特殊、示范性或后果性的损害(包括但不限于替代货物或服务的采购、使用、数据或利润的损失;或业务中断)负任何责任,无论这些损害是由何种行为引起的,以及基于何种责任理论,无论是否已被告知此类损害的可能性。