对于我正在使用的所有人
UITapGestureRecognizer*singleTap = [[[UITapGestureRecognizer alloc] initWithTarget: self action:@selector(doSingleTap:)] autorelease];
singleTap.numberOfTouchesRequired = 2;
[self.view addGestureRecognizer:singleTap
接触
在 doSingleTap: 方法中我有这个
-(void)doSingleTap:(UITapGestureRecognizer *)recognizer
{
CGPoint point = [recognizer locationOfTouch:0 inView:self.view];
NSLog(@"location X =>%f,location =>%f ",point.x,point.y);
CGPoint point1 = [recognizer locationOfTouch:1 inView:self.view];
NSLog(@"location X =>%f,location =>%f ",point1.x,point1.y);
NSLog(@"location X =>%f,location =>%f ",x,y);
UIView *test1 = [[UIView alloc]initWithFrame:CGRectMake(point.x, point1.y, x, y)];
test1.backgroundColor= [UIColor greenColor];
[self.view addSubview:test1];
}
根据手指位置或位置视图在主视图上添加新视图时遇到问题,根据位置视图正确添加视图。
我希望根据两个手指添加该视图并自动调整它们的(x,y,w,h)。如果有人帮助我,我需要帮助在此先感谢我在谷歌上搜索但没有得到任何帮助