3

I am making changes to my app to support 3.5″ display. Currently it is supporting 4″ display. The screen layout looks like this. How to add following constraint in storyboard ? (I have enabled auto layout option in storyboard.)

  1. How to set button1 & button2 width to the half of super view's width ? and both should intersect at the middle of the superview's width.

  2. UIImage #1 should be placed at the middle of the superview's width.

StoryboardView

1 Answer 1

5

1 : Buttons

Didn't figure to do everything in interface builder

You've got to declare an NSLayoutConstraint outlet in your code :

@property (weak, nonatomic) IBOutlet NSLayoutConstraint *buttonWidthConstraint;

and then set :

self.buttonWidthConstraint.constant = self.containerView.frame.size.width /2;

Here is what you have to do in IB :

  • The 2 buttons must have the same width.

First image

  • For both buttons, stick them to the left and right, and bottom, and fix their height like this :

Second image

2 : Center image view

Center the image view like this

center image view

Fix it's width, height, and Y position

fix width height

Hope this helps.

Sign up to request clarification or add additional context in comments.

1 Comment

You can simply add a width constraint (in IB) from the button to the container view with the multiplier being 1:2 (or 0.5) to achieve the 'half width' constraint.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.