使用用户触摸输入更改视图大小 [英] Changing View size using user touch input

查看:89
本文介绍了使用用户触摸输入更改视图大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用用户触摸输入更改我的视图大小。

I want to change my view size using user touch input.

我所知道并将尝试使用TouchesMoved方法然后找到视图的最近顶点触摸,使用动画使视图在该方向上增加。

What I know and will be trying is using TouchesMoved method and then finding the nearest vertex of the view to the touch, make the view increase in that direction using animation.

但是在我开始之前我遇到的问题很少。

But there are few problems I have before I start.

1)相机应用程序在裁剪照片时具有相同的功能。有一个显示实际裁剪区域的网格。我不知道如何显示该网格。我对opengl一无所知。我想将其作为用户处于编辑模式的指示?

1) The camera app has same functionality in cropping photo. There is a grid displaying actual crop area. I don't know how to display that grid. I don't have any knowledge of opengl. I would like to have that as a indication of user is in edit mode?

2)相机应用裁剪功能也是使用用户触摸输入改变大小但是它如果触摸位于视图的四个顶点附近,则仅更改视图大小。据我所知,有一种方法可以检查触摸是否在特定的矩形 CGRectContainsPoint 中,但是如何将其过滤到视图的边界?

2) The camera app crop functionality is also of changing the size using user touch input but it only changes view size, if the touch is near the four vertices of the view. From what I know there is a method to check if the touch is in a specific rect CGRectContainsPoint but how do I filter it to bounds of the view?

修改

我尝试了从Git下载的yinkou回答。

I tried yinkou answer, downloaded from Git.

现在真正的问题是在git Xcode项目中。有一个视图将图像作为contentView,如果用户拖动该视图,图像也会根据视图大小调整来改变形状。

Now the real question is in the git Xcode project. There is a view which has image as a contentView and if user drag that view, the image also changes shape based on view resizing.

我在相机应用程序中执行此操作。我将AVCaptureVideoPreviewLayer作为contentView附加。现在我的视图正在调整大小,但AVCaptureVideoPreviewLayer保持相同的大小。我做错了还是AVCaptureVideoPreviewLayer不会增加?

I am doing this in a camera app. I attached AVCaptureVideoPreviewLayer as a contentView. Now my view is resizing but the AVCaptureVideoPreviewLayer stays the same size. Am I doing something wrong or is it that AVCaptureVideoPreviewLayer won't increase?

推荐答案

幸运的是,那里有一个控件:

And happily, there's a control out there:

https://github.com/spoletto/SPUserResizableView

这篇关于使用用户触摸输入更改视图大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆