views:

67

answers:

1

I want to display a handle at the corners of a UIView that can be used to resize the view. How can I display the handles floating on the top of everything else and still have a connection to and be in sync with a view?

The solution I implemented before looks like this:

alt text

I put the view into another view that shows the handles on top of the corners. The problem with this approach is that the handles add extra space to the original view's size. Since Apple recommends at least 40 x 40 px for the size of a button, it is not very little space and also goes beyond the visible bounds of the original view. Also when I want to align the original views border with its superviews border, parts of the handle buttons become untouchable. Another problem is that the original view has to be encapsulated in this 'helper view' object and thus becomes a part of something although it really is the main component.

A: 

You could make your frame view larger than the actual content, and then inset the content. That's probably the simplest way. You could also use views that weren't subviews of the frame view, but then you run into problems of synchronizing the handle with the content view, as you mentioned. I'd recommend the first option.

Ben Gottlieb
This is exactly what I described above and what's not good enough.
Christian
You described my second suggestion, which is why I recommended the first.
Ben Gottlieb
Okay. But as I described in the second part of my question, I don't like this solution and I'm looking for a way to implement a better one (probably with the approach I mentioned and you don't recommend).
Christian
Sorry, I wasn't clear. I was suggesting just using one view, and drawing all the additional content yourself, rather than adding a complex view hierarchy. I'm not sure I understand your objections; if you make your view 2px larger in each direction, that gives you the save to draw 40px handles.
Ben Gottlieb