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;

        }

  • 相关阅读:
    C#多线程参数传递
    Delphi单元测试工具Dunit介绍
    使用javascript生成文件
    Windows自动登录源码
    [Win32]一个调试器的实现
    用MASM写一个简单的实现递归操作的汇编程序,所谓递归,上课已经跟大家说清楚了,如果我们只考虑简单的只分一次的递
    C#多线程编程(4)多线程与UI操作
    在Delphi中实现类型安全的容器,Delphi泛型库DGL引介(提供源码下载) .
    delphi 中几种多线程操作方式
    C#实现WEB服务器
  • 原文地址:https://www.cnblogs.com/ytmaylover/p/5049242.html
Copyright © 2011-2022 走看看