91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

UITouch觸摸與手勢

發布時間:2020-09-21 02:36:20 來源:網絡 閱讀:467 作者:jna_114 欄目:開發技術

UITouch觸摸與手勢

1. //延遲調用單擊事件,以便雙擊時可取消單擊調用

        [selfperformSelector:@selector(singleTap) withObject:nilafterDelay:0.2];

2. //類方法取消單擊調用方法,及時調用雙擊方法

        [NSObjectcancelPreviousPerformRequestsWithTarget:selfselector:@selector(singleTap) object:nil];

3.self.clipsToBounds= YES//當子視圖越界時,剪切子視圖

幾種常用的手勢

//創建手勢視圖

    UIView *gestureView = [[UIViewalloc]initWithFrame:CGRectMake(10, 20, 300, 300)];

    gestureView.backgroundColor = [UIColororangeColor];

    UILabel *label = [[UILabelalloc]initWithFrame:CGRectMake(100, 400, 100, 50)];

    label.text = @"0";

    label.textAlignment = NSTextAlignmentCenter;

    label.backgroundColor = [UIColorblueColor];

    label.tag = 100;

    [self.viewaddSubview:label];

    [self.viewaddSubview:gestureView];

   

   

    /******************點擊手勢*******************/

    UITapGestureRecognizer *tap1 = [[UITapGestureRecognizeralloc]initWithTarget:selfaction:@selector(tap1Action:)];

    //點擊的數量---點擊的次數

    tap1.numberOfTapsRequired = 1;

    //點擊的個數-----手指的個數

    tap1.numberOfTouchesRequired = 1;

    [gestureView  addGestureRecognizer:tap1];

   

    //單手雙擊

UITapGestureRecognizer *tap2 = [[UITapGestureRecognizeralloc]initWithTarget:selfaction:@selector(tap2Action:)];

    tap2.numberOfTouchesRequired = 2;//雙手雙擊

    tap2.numberOfTapsRequired = 2;

    [gestureView addGestureRecognizer:tap2];

    //如果tap2觸發了.tap1則失效-----雙擊時,單擊失效

    [tap1 requireGestureRecognizerToFail:tap2];

   

    /******************輕掃手勢***********************/

    UISwipeGestureRecognizer *swip1 = [[UISwipeGestureRecognizeralloc]initWithTarget:selfaction:@selector(swip1Action:)];

    [gestureView addGestureRecognizer:swip1];

   

    /******************平移手勢***********************/

    UIPanGestureRecognizer *pan1 = [[UIPanGestureRecognizeralloc]initWithTarget:selfaction:@selector(pan1Action:)];

    [gestureView addGestureRecognizer:pan1];

   

    /******************長按手勢***********************/

    UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizeralloc]initWithTarget:selfaction:@selector(longPressAction:)];

    [gestureView addGestureRecognizer:longPress];

   

    /******************旋轉手勢***********************/

    UIRotationGestureRecognizer *rotation = [[UIRotationGestureRecognizeralloc]initWithTarget:selfaction:@selector(rotationAction:)];

    [gestureView addGestureRecognizer:rotation];

   

    /******************捏合手勢***********************/

    UIPinchGestureRecognizer *pinch = [[UIPinchGestureRecognizeralloc]initWithTarget:selfaction:@selector(pinchAction:)];

    [gestureView addGestureRecognizer:pinch];

 

 

   

   

}

/******************點擊手勢*******************/

//單擊

- (void)tap1Action:(UITapGestureRecognizer *)tap1

{

    NSLog(@"單擊");

    UILabel *label = (UILabel *)[self.viewviewWithTag:100];

    label.text = @"單擊";

}

//雙擊

- (void)tap2Action:(UITapGestureRecognizer *)tap2

{

    NSLog(@"雙擊");

    UILabel *label = (UILabel *)[self.viewviewWithTag:100];

    label.text = @"雙擊";

}

/******************輕掃手勢***********************/

- (void)swip1Action:(UISwipeGestureRecognizer *)swip1

{

//    NSLog(@"輕掃");

    UILabel *label = (UILabel *)[self.viewviewWithTag:100];

    if (swip1.direction == UISwipeGestureRecognizerDirectionRight) {

        label.text = @"向右輕掃";

    }elseif (swip1.direction == UISwipeGestureRecognizerDirectionLeft){

        label.text = @"向左輕掃";

    }elseif (swip1.direction == UISwipeGestureRecognizerDirectionUp){

        label.text = @"向上輕掃";

    }elseif (swip1.direction == UISwipeGestureRecognizerDirectionDown){

        label.text = @"向下輕掃";

    }

}

/******************平移手勢***********************/

- (void)pan1Action:(UIPanGestureRecognizer *)pan1

{

//    UILabel *label = (UILabel *)[self.viewviewWithTag:100];

    CGPoint p1 = [pan1 locationInView:pan1.view];

    NSLog(@"平移的坐標是:%@",NSStringFromCGPoint(p1));

}

/******************長按手勢***********************/

- (void)longPressAction:(UILongPressGestureRecognizer *)longPress

{

    UILabel *label = (UILabel *)[self.viewviewWithTag:100];

    if (longPress.state == UIGestureRecognizerStateBegan) {

        label.text = @"開始長按";

    }elseif (longPress.state == UIGestureRecognizerStateEnded){

        label.text = @"長按結束";

    }

   

}

/******************旋轉手勢***********************/

- (void)rotationAction:(UIRotationGestureRecognizer *)rota

{

//    UILabel *label = (UILabel *)[self.viewviewWithTag:100];

    //旋轉的弧度

    CGFloat r = rota.rotation;

    NSLog(@"旋轉的弧度是:%.2f",r);

    NSLog(@"旋轉的角度是:%.2f",180 * r / M_PI);

   

}

/******************捏合手勢***********************/

- (void)pinchAction:(UIPinchGestureRecognizer *)pinch

 

{

    //獲得捏合的比例

    CGFloat scale = pinch.scale;

    pinch.view.transform = CGAffineTransformMakeScale(scale, scale);

}

 


向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

柯坪县| 红安县| 邢台县| 洞口县| 江达县| 丰台区| 邯郸县| 库尔勒市| 湘西| 宁安市| 岗巴县| 盘锦市| 东平县| 玛纳斯县| 丰县| 喜德县| 伽师县| 介休市| 南京市| 化州市| 青海省| 马边| 沙河市| 海门市| 利辛县| 常德市| 鄢陵县| 临沭县| 大城县| 合水县| 邓州市| 花莲县| 双柏县| 四平市| 海阳市| 化隆| 手游| 蓝山县| 平阳县| 涟源市| 克什克腾旗|