zoukankan      html  css  js  c++  java
  • [翻译] ZLSwipeableView

    ZLSwipeableView

    A simple view for building card like interface like Tinder and Potluck. ZLSwipeableView was originally developed for Murmur.

    一个简单的view,效果类似于卡牌,ZLSwipeableView最初是用于Murmur应用的开发.

    Preview

    Swipe

    Swipe Cancel

    Swipe Programmatically

    CocoaPods - 用CocoaPods安装

    You can install ZLSwipeableView through CocoaPods adding the following to your Podfile:

    你可以通过CocoaPods来安装这个文件:

    pod 'ZLSwipeableView'
    

    Usage - 使用

    Check out the demo app for an example.

    你可以在示例中查看使用方法.

    ZLSwipeableView can be added to storyboard or instantiated programmatically:

    ZLSwipebleView可以直接在storyboard中使用或者是直接实例化出来:

    ZLSwipeableView *swipeableView = [[ZLSwipeableView alloc] initWithFrame:self.view.frame];
    [self.view addSubview:swipeableView];

    ZLSwipeableView must have an object that implements ZLSwipeableViewDataSource to act as a data source. ZLSwipeableView will prefetch three views in advance to animate them.

    ZLSwipeableView必须有一个对象,这个对象是作为data source来使用的.

    // required data source
    self.swipeableView.dataSource = self;
    
    #pragma mark - ZLSwipeableViewDataSource
    - (UIView *)nextViewForSwipeableView:(ZLSwipeableView *)swipeableView {
      return [[UIView alloc] init];
    }

    The demo app includes examples of both creating views programmatically and loading views from Xib files that use Auto Layout.

    ZLSwipeableView can have an optional delegate to receive callback.

    demo中已经包含了通过Xib和普通模式创建出来view的例子,ZLSwipeableView能够通过可选的协议来接受回调.

    // optional delegate
    self.swipeableView.delegate = self;
    
    #pragma mark - ZLSwipeableViewDelegate
    - (void)swipeableView:(ZLSwipeableView *)swipeableView didSwipeLeft:(UIView *)view {
        NSLog(@"did swipe left");
    }
    - (void)swipeableView:(ZLSwipeableView *)swipeableView didSwipeRight:(UIView *)view {
        NSLog(@"did swipe right");
    }
    - (void)swipeableView:(ZLSwipeableView *)swipeableView didCancelSwipe:(UIView *)view {
      NSLog(@"did cancel swipe");
    }
    - (void)swipeableView:(ZLSwipeableView *)swipeableView didStartSwipingView:(UIView *)view atLocation:(CGPoint)location {
        NSLog(@"did start swiping at location: x %f, y%f", location.x, location.y);
    }
    - (void)swipeableView:(ZLSwipeableView *)swipeableView swipingView:(UIView *)view atLocation:(CGPoint)location  translation:(CGPoint)translation {
        NSLog(@"swiping at location: x %f, y %f, translation: x %f, y %f", location.x, location.y, translation.x, translation.y);
    }
    - (void)swipeableView:(ZLSwipeableView *)swipeableView didEndSwipingView:(UIView *)view atLocation:(CGPoint)location {
        NSLog(@"did start swiping at location: x %f, y%f", location.x, location.y);
    }

    To swipe the top view programmatically:

    滑动顶部的view:

    [self.swipeableView swipeTopViewToLeft];
    [self.swipeableView swipeTopViewToRight];

    To discard all views and reload programmatically:

    弃用所有的view,然后重新加载:

    [self.swipeableView discardAllSwipeableViews];
    [self.swipeableView loadNextSwipeableViewsIfNeeded];

    Requirements - 需要的环境

    • iOS 7 or higher. iOS7及以上
    • Automatic Reference Counting (ARC). ARC

    Credits

    • Thanks iamphill for adding new delegates.
    • Thanks mdznr for making the code style consistent.
    • Thanks coryalder for making dataSource and delegate IBOutlets.

     

  • 相关阅读:
    1000F.One Ocurrence(可持久化线段树+思维)
    P2184.贪婪大陆(思维+树状数组)
    438D.The Child and Sequence(线段树+取模性质)
    P2894 [USACO08FEB]Hotel G(线段树维护区间子串)
    620E New Year Tree(线段树维护状压)
    P6492 [COCI2010-2011#6] STEP(线段树维护最长子串)
    242E.XOR on segment(线段树维护区间异或)
    1527D.MEX Tree(树上分类讨论+容斥)
    解决for循环中写异步函数,异步函数中输出下标一样问题
    vue拦截器
  • 原文地址:https://www.cnblogs.com/YouXianMing/p/4237239.html
Copyright © 2011-2022 走看看