Parallax scrolling effect on UITableView header view when scrolled, built using Swift.
Copy ParallaxHeader.swift
into your project.
Create a reference to the ParallaxHeader class:
let parallaxHeader = ParallaxHeader()
In viewDidLoad()
set the tableheader to the parallax header:
tableView.tableHeaderView = parallaxHeader.parallaxHeaderViewWithImage(UIImage(named: "HeaderBackground")!, headerSize: CGSizeMake(tableView.frame.size.height, 300))
parallaxHeader.layoutHeaderViewForScrollViewOffset(self.tableView.contentOffset)
Override the scrollViewDelegate method:
override func scrollViewDidScroll(scrollView: UIScrollView) {
parallaxHeader.layoutHeaderViewForScrollViewOffset(scrollView.contentOffset)
}
Heavily influenced on ParallaxTableViewHeader by Vinodh-G