LuckyLuke
LuckyLuke

Reputation: 49087

Using UIView as containers

I am making a universal app. And even though I set the autoresizing masks on some of the components I need to "group" them. I want each group to be proportionally repositioned, but not each component. Is it bad or are other ways than add them to invisible UIView's so I can group them.

enter image description here

Upvotes: 2

Views: 260

Answers (3)

Moszi
Moszi

Reputation: 3236

i would say you could create a grouped control :) or something similar. Then you can add all your subviews as you suggested to this grouped control, then you resize this group control ... I believe there is nothing wrong with this solution, unless you do not overuse it, and say add 100 grouped views ... that's a bit of an overhead, and i would choose another solution.

However if you add only of couple of them i would go for it ...

Upvotes: 2

Steven Kramer
Steven Kramer

Reputation: 8513

Your idea is spot-on. It's a best practice as far as I'm aware, and empty views are cheap (in the sense there's no extra memory used for the container view's layer).

Upvotes: 3

Rayfleck
Rayfleck

Reputation: 12106

No, it's not bad. If they behave the way you want them to and don't leak or cause performance problems, go for it.

Upvotes: 2

Related Questions