UIPanGestureRecognizer *panTagGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePan:)];[panTagGesture setDelegate:self];[blackanimatevIEw addGestureRecognizer:panTagGesture]; -(voID) handlePan:(UIGestureRecognizer*)panGes{ CGPoint point = [panGes locationInVIEw:girlimagevIEw]; if (point.x < girlimagevIEw.bounds.size.wIDth) { CGRect newframe = CGRectMake(point.x,point.y,blackanimatevIEw.frame.size.wIDth,blackanimatevIEw.frame.size.height); blackanimatevIEw.frame = newframe; } if (point.y < girlimagevIEw.bounds.size.height-160) { CGRect newframe = CGRectMake(point.x,blackanimatevIEw.frame.size.height); blackanimatevIEw.frame = newframe; } }@H_404_7@任何帮助,将不胜感激.解决方法
- (voID)handlePan:(UIGestureRecognizer*)panGes {CGPoint point = [panGes locationInVIEw:girlimagevIEw];CGRect girlimageVIEwBounds = girlimagevIEw.bounds;CGRect blackAnimateVIEwFrame = blackanimatevIEw.frame;CGfloat newX = MIN(point.x,girlimageVIEwBounds.size.wIDth - blackAnimateVIEwFrame.size.wIDth);newX = MAX(newX,0.0f);CGfloat newY = MIN(point.y,girlimageVIEwBounds.size.height - blackAnimateVIEwFrame.size.height);newY = MAX(newY,0.0f);blackAnimateVIEwFrame.origin.x = newX;blackAnimateVIEwFrame.origin.y = newY;blackanimatevIEw.frame = blackAnimateVIEwFrame;}@H_404_7@这是代码.如果黑色视图是女孩图像视图的子视图,它应该工作. 总结
以上是内存溢出为你收集整理的ios – 如何将手势限制在UIImageView的范围内?全部内容,希望文章能够帮你解决ios – 如何将手势限制在UIImageView的范围内?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)