Skip to content

Latest commit

 

History

History
77 lines (51 loc) · 1.92 KB

README.md

File metadata and controls

77 lines (51 loc) · 1.92 KB

ZoomyHeader

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.

##Usage


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)
    }
}

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

iOS 8+

Installation

ZoomyHeader is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "ZoomyHeader"

Author

Logan Sease, [email protected]

License

ZoomyHeader is available under the MIT license. See the LICENSE file for more info.