TestsTested | ✗ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Dec 2016 |
SwiftSwift Version | 3.0 |
SPMSupports SPM | ✗ |
Maintained by Logan Sease.
Zoomy header is a way to add an image cell to your UITableView that will zoom in as you scroll up, similar to Twitter and other apps.
import ZoomyHeader
class ViewController: UITableViewController {
//keep a reference to the zoomyHeaderCell
private var imageViewCell : ZoomyHeaderCell?
override func viewDidLoad() {
super.viewDidLoad()
//register zoomyHeaderCell with your tableView
ZoomyHeaderCell.registerZoomyCellIdentifier(tableView)
}
//MARK: TableView
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
//dequeue a zoomyheaderCell
let identifier = "ZoomyHeaderCell"
let cell = tableView.dequeueReusableCellWithIdentifier(identifier, forIndexPath: indexPath)
//set up our header cell with our image, keep our reference to it and tell the class its initial height
if let imageCell = cell as? ZoomyHeaderCell
{
imageCell.fullImageView.image = UIImage(named: "city1.jpg")
imageViewCell = imageCell
imageCell.originalHeight = 300
}
return cell
}
//MARK: Scroll View Delegate
//Notify the header cell that it should adjust as the tableview scrolls
override func scrollViewDidScroll(scrollView: UIScrollView) {
//if we are scrolling the tableview then adjust the scrollview frame accordingly
if let tableview = scrollView as? UITableView, imageCell = imageViewCell
{
imageCell.didScroll(tableview)
}
}
To run the example project, clone the repo, and run pod install
from the Example directory first.
iOS 8+
ZoomyHeader is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "ZoomyHeader"
Logan Sease, [email protected]
ZoomyHeader is available under the MIT license. See the LICENSE file for more info.