TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Jan 2017 |
Maintained by Jordan Morgan, Humber Aquino, Andrew Yates.
Depends on: | |
FLAnimatedImage | >= 0 |
Masonry | >= 0 |
The BFRGifRefreshControl is an extremely lightweight, unintrusive and configurable way to add a .gif to refreshing actions inside of your iOS app
The BFRGifRefreshControl is hosted on CocoaPods and is the recommended way to install it:
pod 'BFRGifRefreshControl'
To get going, you can either initialize the .gif from your app bundle or via NSData
which can be retrived from a network call or other means.
The flow is consists of adding it your table view, setting your desired offset values for your situation and then calling [refreshControl containingScrollViewDidEndDragging]
from your tableview instance's scrollViewDidEndDragging:willDecelerate:
.
Here is a quick example:
self.gifRefresh = [[BFRGifRefreshControl alloc] initWithGifFileName:@"myGif" refreshAction:^ {
//Calls [self.gifRefresh stopAnimating] inside of performFakeDataRefresh
[self performFakeDataRefresh];
}];
self.gifRefresh.dataRefreshOffsetThreshold = 100.0f; //Trigger refresh after user has scrolled this far
self.gifRefresh.dataRefreshingGifYInset = 115.0f; //Where we want the gif to "hang out" while it performs the block
self.gifRefresh.dataLoadedYInset = 64.0f; //Account for navbar
self.gifRefresh.dataLoadedYOffset = -64.0f; //Account for navbar
If you want some additional context, just fire up the demo project and take a peek
Wait - that seems like a good bit of configuration! Why?
automaticallyAdjustsScrollViewInsets
set to YES
or NO
? Those are all valid questions! The BFRGifRefreshControl was designed to be usable no matter the situation you find youself in. We could make assumptions or controll the UIScrollView
via a category, but
every developer faces different situations and those assumptions could sometimes be wrong or lead to some tricky debugging
It's true that most scenarios call for direct opposite values for the Y inset and offset (i.e. 64 and -64) and that the threshold to trigger a refresh just needs to be the same as the control's height - but that's not 100% always the case. For that reason we've opted for those values to be consciously set by the developer
We regularly maintain this code, and you can also rest assured that it's been battle tested against thousands of users in production
We are always happy to talk shop, so feel free to give us a shout on Twitter:
Or, hey - why not work on the BFRGifRefreshControl and get paid for it!? We're hiring!
This project uses MIT License.