Autolayout on button and textfield in ios - uibutton

I have made simple login form containing buttons , image and textfields. i am trying to have same layout for all iphone screens . i tried using autolayout to give same space all around the view but its not providing the required results . here is the screen shot of an unwanted result (there should be an equal amount of space on bottom of "Forget password text"):

you should give fixed bottom space to superView(forget password) constraint higher priority then top spacing constraint b/w forget password and sign_in.
EDIT
give a try
1.fixed bottom spacing b/w forget password and superview and fixed top spacing b/w forget password and sign in
2. the spacing between sign in and password textfield must be less than or equal , so that if phone size decrease it will shrink not other constraint.

Related

Changing button's size based on its content's length, so the button keeps its shape

I have a UIButton which is created programmatically (it can be customised from Interface Builder, though). It is a circular and it looks like this:
Now I'm working on Internationalization and I need to check it for Double-Length Pseudolanguage. The image above is taken when the app language is set to double-length pseudo, but as you can see, the button only shows one word. Here are the constraints of the button:
The title style of the button is plain, its text is centre-aligned, and the line break is set to "Word Wrap".
How to make the button keep its shape but to increase its size when needed (basically, to increase its width and height for the same amount, so it keeps being a circle), so for example, in this case to show two "Menu" words? If you know how to achieve this I would appreciate your help.
Try setting the content compression resistance on the button to required (1000) for horizontal and vertical. It will also depend on the stackViews above and below allowing for the size change.

Autolayout form login in Xcode 8

I have a problem in managing the autolayout of a form of login with these elements
Form login
The elements are an ImageView on the top, two textFields and two buttons in the middle and another button on the bottom.
Does anyone have any advice?
Connect username field to be centered horizontal in container and vertical space between UIImage and leading ,trailing constraints to the view(left and right ,give value to look similar like in photo if you dont have strict size) after just connect all other fields with username field to be equal width and height ,centered horizontal and vertical space between them.Try to make vertical space like in image ,play litle bit try diferent values that match like in form on photo.
"Continue without registration" set center horizontaly and vertical space to bottom layout (vertical space = 16 ,for example)

Interface Builder Constraints --> UITextView flattening out when run

So I am using interface builder (which I don't often use), and I have two storyboards, one for iPhone 5+ and one for iPhone 4. The iPhone 5 one works perfectly.
However, when I run the app in an iPhone 4 or 4s, one of the UITextViews shrinks in size like it has deflated. When I use constraints, I usually put the views where I want them then do Editor -> Resolve AutoLayout Views or something, and normally the views snap into place.
Here is what it looks like in IB:
IB constraints
And this is what I get when I run the app:
The UITextView when I run the app
This is probably a really simple mistake, but I do feel like a bit of a doompf with my pancake like UITextView. Does anyone know what constraints I could add/actions I could take in order to make the UITextView the size it is in the storyboard?
I am in Xcode 6 and I am using auto layout.
Thanks in advance,
Edit Solved:
Firstly, I deleted the 3.5 inch storyboard so I only have one storyboard.
Then I selected the view in question, and fiddled around with the different iPhone sizes. Once I had put constraints that look good on all the devices, I ran it on every phone, and it worked :).
I agree with #Minestroni-Soup that you don't necessarily need to use two distinct storyboards. In any case, here's how I'd approach the problem. First, I'll ignore the horizontal direction because your problem happens in the vertical direction. If you have problems with the horizontal direction, post a new question.
Place constraints of fixed heights between vertically adjacent views in your layout, and also between the top view and the top border, and also between the bottom view and the bottom border. Then create a constraint that sets the height of one UITextView to be the same as the height of the other UITextView. That should solve your problem.
top border
constraint to set a vertical space of some amount
label 1
constraint to set a vertical space of some amount
textview 1
constraint to set a vertical space of some amount
label 2
constraint to set a vertical space of some amount
textview 1
constraint to set a vertical space of some amount
bottom border
Note that the above, alone, doesn't uniquely define the heights of the two text views but if you add a constraint that sets their heights to be the same, then all the constraints together will have a unique solution (because the labels have well-defined default heights).
I hope my explanation is clear enough.

iOS 8 Constraints

I have an application in Xcode with storyboard. I have a label in center and background image.
I added 4 constraints for both label and background image view. But when I run my app on simulator everything probably works, but text does not scale in label.
Can someone help me?
As per you your question.
1.) Set label as vertically and horizontally centre.
2.) Then you need to give it leading and trailing space and you also need give aspect ratio to the label.
3.) Then you to set Alignment,Baseline,Auto shrink,mode and line break.
Please View the below images of how the constraints which i've set and how i've changed the size of text. I've also added result images for iPhone 5,6 and 6 Plus.
Result:
iPhone 6 Plus:
Hope this will solve your problem.
Thats because the text is too big, to be displayed on your chosen device (iPhone 6). What you need to do, is select the label (in storyboard), go to Attibutes Inspector, then set the Autoshrink to Minimum font size, then input your minimum font size.

How to create labels with dynamic size in iOS 6 with autolayout

I'm having trouble with autolayout and labels that get their text set in the source code based on some external conditions. These layouts (portrait and landscape) look like this on the simulator:
http://imgur.com/l6Iirun
http://imgur.com/n7RwwSD
The second one is obviously not what I want it to be, the label with the URN should fill the whole screen.
I have a width constraint for the dynamic label added by Xcode which I can't get rid of even though the "Name"-label has a fixed width and all horizontal spaces are fixed as well which should logically rid me of the need to have a width constraint for the label containing the dynamic text.
Any help on how to achieve what I want? Thanks in advance!
It looks to me like your labels are not binding their trailing edge to the superview. In the lower right there is the little 'I beam' icon, click on your label and then that icon, the top of the menu should be 'Pin' and pick trailing edge to superview. The label should expand to fit the width of the screen, minus some padding. Once that is in place you should be able to remove the width constraint - although you may need to find it in the size inspector and select promote to user constraint before you can remove it.
If you don't see the pin menu, try going up to the top and picking Editor -> Pin and you should see it there.
If it is already pinned, try increasing the content compression resistance priority and decreasing the priority of the width - although if pinning it does not fix it then there is another constraint at play.