• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
hellowbabybaby
博客园    首页    新随笔    联系   管理    订阅  订阅

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;

    }

posted @ 2015-12-15 19:33  hellowbabybaby  阅读(133)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3