zoukankan      html  css  js  c++  java
  • xcode

    #import "ViewController.h"
    
    @interface ViewController ()
    
    /**
     创建一个UIView
     */
    @property(nonatomic , weak) UIView * gestureView;
    
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        //创建一个uiview
        UIView * tempView = [[UIView alloc]initWithFrame:CGRectMake(20, 20, 100, 100)];
        //设置背景颜色
        tempView.backgroundColor = [UIColor orangeColor];
        self.gestureView=tempView;
        //创建手势
        UIPanGestureRecognizer * pan = [[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(panGes:)];
        //绑定手势
        [self.gestureView addGestureRecognizer:pan];
        [self.view addSubview:self.gestureView];
    }
    
    - (void)panGes:(UIPanGestureRecognizer *)pan{
        CGPoint tranP = [pan translationInView:self.gestureView];
        self.gestureView.transform = CGAffineTransformTranslate(self.gestureView.transform, tranP.x, tranP.y);
        [pan setTranslation:CGPointZero inView:self.gestureView];
    }
    
    - (void)didReceiveMemoryWarning {
        [super didReceiveMemoryWarning];
        // Dispose of any resources that can be recreated.
    }
    
    @end
    
  • 相关阅读:
    打造自定义 eslint
    二叉树(三): 二叉查找树
    二叉树(二): 补充
    二叉树(一): 遍历
    redux 源码浅析
    react-redux 源码浅析
    WebComponents使用以及思考
    SHELL 语法以及实例
    React-Native 原生 APP 更新
    关于 cdn 在项目中的使用
  • 原文地址:https://www.cnblogs.com/fleas/p/5618601.html
Copyright © 2011-2022 走看看