SamuelTJackson
SamuelTJackson

Reputation: 1537

Let the user change the size of a Container in swift

I want to have three containers on one UIViewController. The user should be able to change the size of the containers like the textfield here in stackoverflow. So the user can change the size with his finger. The user grap a point in the container an pull it at the size he wants. I couldn't find any example. I don't even find a starting point. I hope someone has an idea.

Upvotes: 1

Views: 79

Answers (2)

Olivier Stepien
Olivier Stepien

Reputation: 31

I have done something similar. I put some buttons on each side of the view and handle the action with the events UIControlEvents.TouchDragInside and .TouchDragOutside. You can then use the UIEvent to get the position of the touch in the view and change the size of the view or the contraints (depending if you use autolayout or not).

Upvotes: 0

dersvenhesse
dersvenhesse

Reputation: 6414

I'd use a UIPanGestureRecognizer and calculate the dragging distance to increase the views frame by that.

Upvotes: 1

Related Questions