控件总结(四)

//UItouchcode

// 容许多点触发
[self.view setMultipleTouchEnabled:YES];

// 单击或者移动时会触发这个方法,而且只会调用一次ip

  • (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ NSLog(@"%s",func);rem

    NSLog(@"%@",touches); //
    UITouch * touch = [touches anyObject]; NSLog(@"%f",touch.timestamp); // 时间戳it

    NSLog(@"%@",touch.view); // 打印手势触发的当前的视图io

    NSLog(@"%ld",touch.phase); // 触发时的阶段xevent

    NSLog(@"%ld",touch.tapCount); // 点击的次数方法

}im

// 单击或者移动结束会触发这个方法,而且只会调用一次时间戳

  • (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{ NSLog(@"%s",func); }

// 在屏幕上移动,会屡次调用touch

  • (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{ NSLog(@"%s",func);

    UITouch * touch = [touches anyObject];

// 获取上一个点的坐标 // 相对于后面的参数这个view的坐标 CGPoint prePoint = [touch previousLocationInView:self.view];

NSLog(@"%@",NSStringFromCGPoint(prePoint));

// 获取当前点的坐标 CGPoint currentPoint = [touch locationInView:self.view]; NSLog(@"%@",NSStringFromCGPoint(currentPoint));

CGFloat x = currentPoint.x - prePoint.x;
CGFloat y = currentPoint.y - prePoint.y;

_myView.center = CGPointMake(_myView.center.x+x, _myView.center.y+y);

} // 发生中断(好比有来电时)进行调用

  • (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event{ NSLog(@"%s",func); } @end //UIView控件 // 从父视图上移除某个view [view5 removeFromSuperview]; // 把某个视图移动到最上面 [self.view bringSubviewToFront:view1]; // 把某个视图移动到最下面 [self.view sendSubviewToBack:view1]; // 把某个视图放到另一个视图的上面 [self.view insertSubview:view1 aboveSubview:view3]; // 把某个视图放到指定的位置 [self.view insertSubview:view1 atIndex:1]; // 交换两个视图 [self.view exchangeSubviewAtIndex:0 withSubviewAtIndex:1]; // 控件的响应关系:能够响应用户操做的控件,若是他的大小有有一部分超出父视图,那么超出父视图的部分是不参与用户响应的,只有在父视图内的部分才会有响应。 //页面之间的跳转 // [self dismissViewControllerAnimated:YES completion:^{}]; ThirdViewController * thrid = [[ThirdViewController alloc]init]; [self presentViewController:thrid animated:YES completion:^{}];

}

  • (void)buttonWithClickToFirst{ [self dismissViewControllerAnimated:YES completion:^{}]; }
相关文章
相关标签/搜索