zoukankan      html  css  js  c++  java
  • UIPanGestureRecognizer UIScreenEdgePanGestureRecognizer

    Configuring the Gesture Recognizer

    @property(nonatomic) NSUInteger maximumNumberOfTouches//The maximum number of fingers that can be touching the view for this gesture to be recognized.
    @property(nonatomic) NSUInteger minimumNumberOfTouches//The minimum number of fingers that can be touching the view for this gesture to be recognized.
    

    Tracking the Location and Velocity of the Gesture

    - (CGPoint)translationInView:(UIView *)view//The translation of the pan gesture in the coordinate system of the specified view.平移的距离。设置后速度为0.
    - (void)setTranslation:(CGPoint)translation inView:(UIView *)view//设置平移的距离
    - (CGPoint)velocityInView:(UIView *)view//速度。 which is expressed in points per second.
    

    例子

    方法1:

        CGFloat translationX = [pan translationInView:self.view].x;
        pan.view.center = CGPointMake(pan.view.center.x+translationX, pan.view.center.y);
        [pan setTranslation:CGPointZero inView:self.view];

    方法2:

    CGPoint translation = [recognizer translationInView:recognizer.view];
    
    case UIGestureRecognizerStateBegan: {
                [recognizer setTranslation:CGPointMake(recognizer.view.frame.origin.x, 0) inView:recognizer.view];
                break;
            }
            case UIGestureRecognizerStateChanged: {
                [recognizer.view setTransform:CGAffineTransformMakeTranslation(MAX(0,translation.x), 0)];            
                [self statusBarView].transform = recognizer.view.transform;
                break;
            }
    

    目前看来,translationInView的参数是attach的view还是其父view关系不大。每次的translation都是与上次的叠加。因此如果每次设置为0,则累加坐标即可。否则要用setTransform。

    UIScreenEdgePanGestureRecognizer

    UIScreenEdgePanGestureRecognizer looks for panning (dragging) gestures that start near an edge of the screen. The system uses screen edge gestures in some cases to initiate view controller transitions. You can use this class to replicate the same gesture behavior for your own actions.

    @property(readwrite, nonatomic, assign) UIRectEdge edges

    The edges you specify are always relative to the app’s current interface orientation. This behavior ensures that the gestures always occur from the same place in your user interface, regardless of the device’s current orientation.

    UIRectEdge的值如下:

    typedef enum : NSUInteger  {
       UIRectEdgeNone    = 0,
       UIRectEdgeTop     = 1 << 0,
       UIRectEdgeLeft    = 1 << 1,
       UIRectEdgeBottom  = 1 << 2,
       UIRectEdgeRight   = 1 << 3,
       UIRectEdgeAll  = UIRectEdgeTop  | UIRectEdgeLeft  | UIRectEdgeBottom  | UIRectEdgeRight 
    } UIRectEdge;
    
  • 相关阅读:
    FreeSql (二十)多表查询 WhereCascade
    FreeSql (十九)多表查询
    FreeSql (十八)导航属性
    FreeSql (十七)联表查询
    FreeSql (十六)分页查询
    C#实现.Net对邮件进行DKIM签名和验证,支持附件,发送邮件签名后直接投递到对方服务器(无需己方邮件服务器)
    C#的RSA加密解密签名,就为了支持PEM PKCS#8格式密钥对的导入导出
    Zookeeper Windows版的服务安装和管理工具
    Nginx Windows版的服务安装和管理工具
    1kb的前端HTML模板解析引擎,不限于嵌套、循环、函数你能想到的解析方式
  • 原文地址:https://www.cnblogs.com/zhongriqianqian/p/3986322.html
Copyright © 2011-2022 走看看