LanarsInc / LNParallaxTVCell

UITableViewCell with parallax effect

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

LNParallaxTVCell - Swift

iOS Platform Swift 5.0 License

A subclass of UITableViewCell to present the parallax effect. You won't use UITableViewDelegate or something else, you can use it simply like UITableViewCell, or customize parallax ratio or another properties.

Preview

Installation

To install via CocoaPods add this lines to your Podfile:

pod 'LNParallaxTVCell'

To install manually LNParallaxTVCell in an app, just drag LNParallaxTVCell.swift class into your project

Usage

  1. Import LNParallaxTVCell module to your class
import LNParallaxTVCell
  1. Set your UITableViewCell class as LNParallaxTVCell in storyboard or .xib file

  2. Set your image as "parallaxImage" to display

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. Optional - You can change parralaxRatio from 0.0 to 1.0 (default value is 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
}

Also check out an example project with parralax table view cell

License

Copyright © 2019 Lanars

https://lanars.com

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

About

UITableViewCell with parallax effect

License:BSD 2-Clause "Simplified" License


Languages

Language:Swift 90.3%Language:Ruby 9.7%