chipbk10
chipbk10

Reputation: 5955

How to keep subview's position relative to its parent view?

I have a parent view (UIView), that contains 2 buttons (UIButton). These buttons are always on the bottom of the parent view. Now, when I make animation for the parent view (like increase its height), I want these 2 buttons should keep their previous relative position (should be on the bottom).

In the Size Inspector, I set the Origin of the button like

inspector

However, it doesn't work. Is there any simple solution for that? I don't want to write it in the code, because I have so many sub views, and want them keep their relative position in comparison to the parent view. Manually doing it in the code is really a hard work.

Note: I am using XCode 5, iOS 7

Upvotes: 0

Views: 381

Answers (1)

kylejs
kylejs

Reputation: 1128

If you're using Xcode 5, you can use the new auto-layout buttons in IB:

enter image description here

You can then just pin your views to the bottom of the parent view in a similar way you would in the size inspector. You may need to add additional constraints, but Xcode can do this for you.

Upvotes: 1

Related Questions