How to create resizable view with handlers on side

2019-03-04 17:11发布

问题:

This question already has an answer here:

  • Changing View size using user touch input 1 answer

I am creating an app where user touch the screen and places a rectangle view on screen which he can move or resize by touching its corners like any other crop view . I have done this functionality but i want eight handlers on the sides of that rectangle so that user can use that handlers to resize it. Now i am unable to create such functionality . I tried to add eight buttons as subview on that rectangle view but when resizing when that view increase its size than all eight buttons just change their positions . can anybody help me with this functionality ?

Thanks in advance

回答1:

Hi i got the answer from here . here is a great class for making resizable view. Great work by the developer

Create resizable view in ios with UITouch



回答2:

To do this you are going the right way about it.

You need to create a custom view that positions these eight handles depending on the size of the view. When the view changes size you then need to reassess where those handles are so maybe have a function thats called when the view is resized and in here you change the location of each handle just by changing its x and y origin depending on the view size.