• Using UIGestureRecognizer


    - (void)viewDidLoad
    {
        [super viewDidLoad];
        // Do any additional setup after loading the view.   
    
        [MoveMe.titleLabel setText:NSLocalizedString(@"Move Me Now!",@"")];
    
      // Init
    UIPanGestureRecognizer * mPanGR = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(onMoveMePan:)];
     // add To MoveMe [MoveMe addGestureRecognizer:mPanGR]; } - (void) onMoveMePan:(UIPanGestureRecognizer *)gestureRecognizer { UIView * v = [gestureRecognizer view]; if (v == MoveMe ) {
        //Get Locations Before Modify Any Thing ,!!! It'w may reset locations while you change other options,such like Text CGPoint translation
    = [gestureRecognizer translationInView:[v superview]]; CGPoint center= MoveMe.center; if ([gestureRecognizer state] == UIGestureRecognizerStateBegan || [gestureRecognizer state] == UIGestureRecognizerStateChanged) { [MoveMe.titleLabel setText:NSLocalizedString(@"Moving!",@"")]; //Move !!! must be happen after alter other options; translation.x += center.x; translation.y += center.y; v.center = translation; } if ([gestureRecognizer state] == UIGestureRecognizerStateEnded) { MoveMe.titleLabel.text = NSLocalizedString(@"Move End",@"");
            //Move translation.x
    += center.x; translation.y += center.y; v.center = translation; }
          // reset the Offect Vector to zero offter handled [gestureRecognizer setTranslation:CGPointZero inView:v.superview]; } }
    - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } - (void)dealloc { [MoveMe release]; [super dealloc]; }
  • 相关阅读:
    ubuntu 20.04 安装mysql
    vim 编辑器常用命令备份
    各个Iot Cloud对MQTT协议的支持
    Linux下sleep函数与usleep函数加Windows下的Sleep函数
    localtime、localtime_s、localtime_r的使用
    Windows平台下利用openssl配置产生SSL认证文件
    转载
    转载- 常见arduino型号(版本)比较
    转载
    转载
  • 原文地址:https://www.cnblogs.com/playerc/p/using_uigesturerecognizer.html
Copyright © 2020-2023  润新知