3

How to resize UIView based on its edges?

Actually I am creating UITextField programmatically, and if User want then they can increase and decrease UITextField's height and width by dragging its edges..

I do not want to change its height and width proportionally. If user want height then only height changes and if width then only width.

So I found the solution to take One UIView programmatically and then place UITextField in it..

So My question is, How can we change UIView's height and width by touching on UIView's Edges?

I know all about UIPanGestureRecognizer but don't want that.

I had gone through this stackoverw link. and also got this solution but It is not useful for me..

Please suggest me what to do?

UPDATE

Currently doing work on SPUserResizableView and I think this will be useful..

Thanks to all my friends..

Community
  • 1
  • 1
Mehul Mistri
  • 15,037
  • 14
  • 70
  • 94
  • Why is the first link not useful? It will implement resizing quite nicely. Is there something more specific you're going for? – Miles Alden Dec 01 '12 at 07:49
  • @MilesAlden When you are going with UIPanGestureRecognizer, It will increse width and height proportionally. and I m not going to do that – Mehul Mistri Dec 01 '12 at 08:10
  • @Mehul `UIPanGestureRecognizer` reports both the X and Y offset of the gesture. But you can just ignore the X offset when the user is dragging the height handle, and ignore the Y offset when the user is dragging the width handle. – rob mayoff Dec 04 '12 at 06:25
  • @Mehul Also, you haven't explained *why* `SPUserResizableView` is not useful for you. – rob mayoff Dec 04 '12 at 06:25
  • @robmayoff Sry for not updating my question but I am currently trying to use that for the same.. – Mehul Mistri Dec 04 '12 at 06:28

1 Answers1

-1

It's simple . Have you heard about -

TouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;

TouchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;

TouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;

TouchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event;

You just need to add this methods in your UIView class. then from some sort of calculation you can do that. Say When you touch Touch begain methods get's called ... in Touch move you can move animate for the uiview to increase or decrease height or width. As All the above function will give you coordinate of x and y.

Hope this may help you.

Mehul Mistri
  • 15,037
  • 14
  • 70
  • 94