tags:

views:

36

answers:

1

I have a Drawing app of sorts and am looking for some feedback on ways to draw a selection rectangle, and or the resize grips for a selected view.

So I have a custom class that is inherited from UIView, in it it contains a UIImageView, UILabel, and UIButton. I can have several on the screen at one time. I want to tap on one and draw a selection rectangle around it. From there if i drag I want the view and the selection rectangle to move with it. I would like the Selection Rectangle maybe 4px larger than the exiting bounds rect.

So my question is what is the best way to get the Selection Rectangle around the selected UIView object?

Do I offset the object so what when I add in the UIImageView, UILabel, and UIButton that are part of it I have a 4px buffer around the edges?

Do I adjust the View when selected to reposition the subview, increase the bounds and offset the frame?

Do I just create a new UIView that is 4px larger than the selected object and just move it with the selected view?

Do I just create a new UIView that is 4px larger than the selected object and and make the selected view a subview of it?

or? (your Idea Here...)

Thank you for your comments and Suggestions...

Scooter133

A: 

Consider setting the borderWidth property on your view's layer. Note that this is drawn within the view's bounds, so it may be more useful as a highlight state than a selection rectangle.

Justin
Yeah, that just gives me kind of what I have already. I've used the bounds to draw a dashed line around the 'border' of my UIView. Seems like I need to add my object to another view centered around my view, or?
Scooter133
I'd forgotten about this post from Matt Long that may prove helpful:`http://www.cimgf.com/2009/10/20/marching-ants-with-core-animation/`
Justin