zoukankan      html  css  js  c++  java
  • UI05-‍手势用图片做实验

    /*今日任务:

     1.设计模式: 怎么去实现,两种 2.imageview 图片显示3.手势用图片做实验

     1.设计模式:设计模式的作用:(1)提高代码的可扩展性 (2)提高代码的可读性 偶合度是判断代码优秀的标准。

       设计模式和代码的结合。第一个是taget/action 模式

     2.pch 全局

     作业:完善出自己的button,view好lable组合出button ,.

    - (void)viewDidLoad {

        [super viewDidLoad];

        UITapGestureRecognizer *tap=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapGesture:)];

        [_mainv.swip addGestureRecognizer:tap];

            UILongPressGestureRecognizer *longpress=[[UILongPressGestureRecognizer alloc]initWithTarget:self action:@selector(LongPress:)];

        longpress.minimumPressDuration=1.0;

        [_mainv.longpress  addGestureRecognizer:longpress];

            UISwipeGestureRecognizer *swip=[[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(swipGesture:)];

        [_mainv.longpress addGestureRecognizer:swip];

            UIPanGestureRecognizer *pan=[[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(panGestureRecognizer:)];

        [_mainv.longpress addGestureRecognizer:pan];

          UIPinchGestureRecognizer *pinch=[[UIPinchGestureRecognizer alloc]initWithTarget:self action:@selector(pinchGestureRecognizer:)];

        [_mainv addGestureRecognizer:pinch];

           UIRotationGestureRecognizer *roatation=[[UIRotationGestureRecognizer alloc]initWithTarget:self action:@selector(rotationGesture:)];

        [_mainv addGestureRecognizer:roatation];

    }

    -(void)rotationGesture:(UIRotationGestureRecognizer *)rotation{

        rotation.view.transform=CGAffineTransformMakeRotation(rotation.rotation);

    }

     -(void)pinchGestureRecognizer:(UIPinchGestureRecognizer*)pinch{

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

     }

     -(void)panGestureRecognizer:(UIPanGestureRecognizer *)pan{

         CGPoint offsite=[pan translationInView:self.view];

        pan.view.transform=CGAffineTransformMakeTranslation(offsite.x, offsite.y);

     }

     -(void)swipGesture:(UISwipeGestureRecognizer*)swip{

         swip.direction=UISwipeGestureRecognizerDirectionLeft;

    }

     -(void)LongPress:(UILongPressGestureRecognizer *)longpress{

           if (longpress.state==UIGestureRecognizerStateBegan ) {

            longpress.view.backgroundColor=[UIColor colorWithRed:arc4random()%256/255.0 green:arc4random()%256/255.0  blue:arc4random()%256/255.0  alpha:1.0];

        }

    }

    -(void)tapGesture:(UITapGestureRecognizer *)taptap{

         taptap.view.backgroundColor=[UIColor colorWithRed:arc4random()%256/255.0 green:arc4random()%256/255.0  blue:arc4random()%256/255.0  alpha:1.0];

        taptap.numberOfTapsRequired=2.0;

    //    taptap.numberOfTouchesRequired=2;

        }

  • 相关阅读:
    Flutter Android ERROR: ensureInitializationComplete must be called after startInitialization
    MySQL 创建用户表和好友表
    Android 广播的使用 文档使用的是 kotlin版本
    Flutter 分段器的使用
    Flutter 计算两个日期之间相差多少天,生成区间随机数
    Flutter 多环境
    Android ListView 的使用 Kotlin
    Android 自定义控件----基础
    Flutter 学习(3)------------通过List或者map循环数据渲染页面。。
    vs2015 编译报错:The project references NuGet package(s) that are missing on this computer...
  • 原文地址:https://www.cnblogs.com/ytmaylover/p/5049242.html
Copyright © 2011-2022 走看看