Animated downloader such as Snapchat

I was wondering how snapchat animates this ghostly thing when you go down to freshen up? I wanted to implement this in my application and was wondering how it was done.

+7
objective-c animation
source share
1 answer

I think you need to write your own solution. But it really is not that difficult.

You need to create your own table header view containing the stretched image and implement some processing in the UITableViewDelegate . The following is a fairly general implementation of custom update management processing.

1) create a custom UIView that will be displayed as a drop-down list:

Header file:

 #import <UIKit/UIKit.h> typedef enum UpdateListViewState { UpdateListViewStatePull, UpdateListViewStateRelease, UpdateListViewStateUpdate }UpdateListViewState; @interface UpdateListView : UIView @property (nonatomic,readwrite) UpdateListViewState state; @property (nonatomic,strong) UIImageView imageView; @end 

2) set headerView as tableView header:

 self.header = [[UpdateListView alloc] init]; self.table.tableHeaderView = self.header; 

3) In your UITableViewDelegate do table scroll control:

 const int UPDATE_DRAG_HEIGHT = -70; - (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset { if (self.header.state == UpdateListViewStateRelease) { //Perform update stuff here & perhaps refresh animation self.header.state = UpdateListViewStateInitial; } } -(void)scrollViewDidScroll:(UIScrollView *)scrollView { //adjust size of self.header.imageView here according to scrollView.ContentOffset if (scrollView.contentOffset.y < UPDATE_DRAG_HEIGHT && self.header.state != UpdateListViewStateUpdate) { self.header.state = UpdateListViewStateRelease; } } 
+7
source share

All Articles