SimpleCollapsingHeaderView
SimpleCollapsingHeaderView copied to clipboard
trafficstars
SimpleCollapsingHeaderView
A Simple collapsing header view based on this post

Usage
- Open o storyboard or Xib file.
- Drag and drop a
UIViewto a ViewController - In Identity Inspector, replace the class from
UITextFieldtoSimpleCollapsingHeaderViewand the module toSimpleCollapsingHeaderView. - Configure
Min HeightandMax Heightin the Attribute Inspector - Add the following constraints:
- Trailing Space to Superview
- Leading Space to Superview
- Top Space to Superview
- Height equal to
Max Heightproperty (Unfornutately I still haven't figured a way to update the height constraint based on the@IBInspectable)
- Connect the
Height Constraintto theheaderHeightConstraintof theSimpleCollapsingHeaderView - Connect the
SimpleCollapsingHeaderViewto you ViewController - Call
collapseHeaderView(using: scrollView)inside yourscrollViewDidScroll(_ scrollView: UIScrollView)method
Animations
Animations can be done by implementing the SimpleCollapsingHeaderViewDelegate, the onHeaderDidAnimate returns the percentage of how much the Header view is collapsed
A simple animation can be found inside the example Project
Example
To run the example project, clone the repo, and run pod install from the Example directory first.
Requirements
- Minimum iOS version required: 9.0
TODOs
- Implement the previous scroll inset in a way that you can have more than 1 scrollView resizing the Header View
Installation
SimpleCollapsingHeaderView is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'SimpleCollapsingHeaderView'
Author
Nicholas Meschke, [email protected]
License
SimpleCollapsingHeaderView is available under the MIT license. See the LICENSE file for more info.