Skip to content

Instantly share code, notes, and snippets.

@AlexHedley
Created May 22, 2017 14:12
Show Gist options
  • Save AlexHedley/c551b417c3e02820a1eae04124003ee6 to your computer and use it in GitHub Desktop.
Save AlexHedley/c551b417c3e02820a1eae04124003ee6 to your computer and use it in GitHub Desktop.
- (void)removeItemAtIndex:(NSInteger)index animated:(BOOL)animated {
//Amended method below to slide Up/Down
}
- (void)saveItemAtIndex:(NSInteger)index animated:(BOOL)animated {
index = [self clampedIndex:index];
UIView *itemView = [self itemViewAtIndex:index];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];
[UIView setAnimationDelegate:itemView.superview];
[UIView setAnimationDidStopSelector:@selector(removeFromSuperview)];
[self performSelector:@selector(queueItemView:) withObject:itemView afterDelay:0.1];
itemView.superview.layer.opacity = 0.0;
itemView.frame = CGRectOffset(itemView.frame, 0, 250); //Swap to -250 to change direction
[UIView commitAnimations];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDelay:0.1];
[UIView setAnimationDuration:INSERT_DURATION];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(depthSortViews)];
[self removeViewAtIndex:index];
_numberOfItems --;
_wrapEnabled = !![self valueForOption:iCarouselOptionWrap withDefault:_wrapEnabled];
[self updateNumberOfVisibleItems];
_scrollOffset = self.currentItemIndex;
[self didScroll];
[UIView commitAnimations];
}
@AlexHedley
Copy link
Author

I needed a Carousel like control but swipe up/down actions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment