SWKeyFrameFold 1.0

SWKeyFrameFold 1.0

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Dec 2014

Maintained by Simon Westerlund.



  • By
  • Simon Westerlund

KeyFrameFold

keyframefold

KeyFrameFold is a tool to attach to your favourite UIScrollView, it can then be used to hide the UINavigationBar like Safari does on iOS7

Simply add SWKeyFrameFold.h to your project and in your -scrollViewDidScroll: use the following snippet.

[[SWKeyFrameFold shared] foldUsingScrollView:scrollView       // 1
                 totalHeight:44 + 24          // 2
                   keyPoints:@[@0.0f, @44.0f] // 3
                      blocks:@[(SWKeyFrameFoldBlock)^(CGFloat percentDone, BOOL scrollDirectionDown, CGFloat totalPercentDone) {
    NSLog(@"%f", percentDone);
    },
                           (SWKeyFrameFoldBlock)^(CGFloat percentDone, BOOL scrollDirectionDown, CGFloat totalPercentDone) {
    NSLog(@"%f", percentDone);
    }]];
  1. Use the shared instance and attach your scrollView
  2. Calculate the total height the fold will use as reference, the height here is based on a UINavigationBar and a UIToolBar
  3. Add your keyPoints, i.e. when you want your fold to begin
  4. And last, provide your blocks in an NSArray. The block is a SWKeyFrameFoldBlock and returns
    1. CGFloat percentDone the local percent, 0-1 were 1 is folded
    2. BOOL scrollDirectionDown if the user is scrolling down
    3. CGFloat totalPercentDone the total percent of the folding, 0-1 were 1 is folded.