Pull up, pull down UITableView, interactive mode pop-up (Custom Animation), uitableview Mode

Source: Internet
Author: User

Pull up, pull down UITableView, interactive mode pop-up (Custom Animation), uitableview Mode

 

Part of the Code InteractiveTransition class inherits NSObject:

- (instancetype)initWithPresentingController:(UITableViewController *)presentingVc presentedController:(UIViewController *)presentedVc {    self = [super init];    if (self) {        self.vc = presentedVc;        self.vc.transitioningDelegate =self;        self.presentingVc = presentingVc;    }    return self;}- (void)new_scrollViewWillBeginDragging:(UIScrollView *)scrollView {    self.interactiveTransition = [[UIPercentDrivenInteractiveTransition alloc]init];    [self.presentingVc presentViewController:self.vc animated:YES completion:nil];}- (void)new_scrollViewDidScroll:(UIScrollView *)scrollView {        CGFloat offsetY = fabs(scrollView.contentOffset.y);        CGFloat screenH = [UIScreen mainScreen].bounds.size.height / 3.0;    progress = offsetY / screenH;    progress = progress-0.3;    if (progress > 0) {        [self.interactiveTransition updateInteractiveTransition:progress];    }    }- (void)new_scrollViewWillEndDragging {    if (progress < 0.4) {        [self.interactiveTransition cancelInteractiveTransition];    }else {        [self.interactiveTransition finishInteractiveTransition];    }    self.interactiveTransition = nil;}- (nullable id <UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController:(UIViewController *)presented presentingController:(UIViewController *)presenting sourceController:(UIViewController *)source {        return self.animation;}- (id<UIViewControllerInteractiveTransitioning>)interactionControllerForPresentation:(id<UIViewControllerAnimatedTransitioning>)animator {        return self.interactiveTransition;}

 

The PresentAnimation class inherits NSObject to implement the UIViewControllerAnimatedTransitioning protocol.

- (NSTimeInterval)transitionDuration:(id<UIViewControllerContextTransitioning>)transitionContext {    return 1.0;}- (void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext {        UIView *toView = [transitionContext viewForKey:UITransitionContextToViewKey];    UIView *containerView = [transitionContext containerView];    [containerView addSubview:toView];        toView.frame = CGRectMake(50, containerView.bounds.size.height, containerView.bounds.size.width - 100, containerView.bounds.size.height - 300);        [UIView animateWithDuration:[self transitionDuration:transitionContext] animations:^{        toView.frame = containerView.bounds;    }completion:^(BOOL finished) {        [transitionContext completeTransition:![transitionContext transitionWasCancelled]];    }];    }

Controller:

- (InteractiveTransition *)interactive {    if (!_interactive) {        _interactive = [[InteractiveTransition alloc]initWithPresentingController:self presentedController:[[TwoViewController alloc]init]];    }    return _interactive;}- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {        [self.interactive new_scrollViewWillBeginDragging:scrollView];}- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset {        [self.interactive new_scrollViewWillEndDragging];}- (void)scrollViewDidScroll:(UIScrollView *)scrollView {        [self.interactive new_scrollViewDidScroll:scrollView];}

Full: http://pan.baidu.com/s/1i3Uewip

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.