please how can i have a static width for my Text Fields.
I have a Login View Controller (portrait) in which i have an image (logo of the App), username text field, password text field and a button to log in.
When i run it in an Iphone it looks pretty good, but in Ipad all looks stretched.
What can i do so this elements looks the same in both devices? (i want them to look as the Iphone shows).
I don't want them to resize.
Thanks a lot!
If you want an element to be an exact size you would update the width and height constraints to be your desired number.
Set your textFields width and height properties to your desired size in Attributes inspector panel or do it programmatically.
I would recommend you to use Auto Layout as that will help you make your design beautiful in all resolutions and sizes.
Thanks all for your answer, i erase the "Leading space to container" and "Trailing space to container" in each one of the elements.
It is no resizing anymore :)
Related
What constraints would make this view resize the labels 1-9 with a smaller font and label size in order to keep labels 1-9 within the view. I have tried using minimum font scale and pinning the labels to all sides of the view. Any tips and or help with auto layout and building responsive UI's in Xcode are appreciated thank you.
iPhone 7 Plus screen size simulation
iPhone 4s screen size simulation
It's easy!
You can use constraints like this:
After adding all constraints you need check UILabel configuration:
If you have question - you can ask :)
I think here, you can find answer to your question (Part: Two Equal-Width Views).
A idea lies inside of using additional view between the labels and strengthening first and last labels to a top and a bottom edge of a parent view.
All you have to do is add some NSLayoutConstraints and change some UILabel Properties in the UIStoryBoard Interface Editor .. I have added an image and a gif for reference.
This gif image will give a detailed explanation :
So I have the following layout in storyboards, everything works fine on the 3x screen sizes but I would like to try and tidy up the font sizes and the position of the button icon relative to the button text.
See below what I mean, basically what I want is for each screen size to look very similar to the 4.7 screen layout e.g. the spacing between the text and the icons (also how can I get the font to scale down slightly on the 4 inch screen as it looks too big but ok on the rest of the screens.
Any idea what constraints I need to put on the icons and text to get it to look the same on each screen size.
In auto layout use multiplayer to increase and shrink the element. Please see the example below:
Now run your app and check in all device type. Hope this will work for you.
If you are using autolayout, you can set aspect ratio constraints for width and height of the imageView to the cell content view, that way, if the cell grows image will grow too.
The following link might be useful http://candycode.io/how-to-set-up-different-auto-layout-constraints-for-different-screen-sizes/
I have a view that has a few different blocks of text in it. I need the font sizes of the text to scale down when a user is on an iPhone SE, and scale up when the user is on an iPhone 7 plus, and not do anything on an iPhone 7. Right now the text is staying within the view left and right, but going off the bottom. See the pictures:
Everything looks good here:
The content is staying within the bounds left and right, but not shrinking to fit here:
Any ideas for what I'm doing wrong?
Using a Stack View seems to be the way to go. Happy to give credit to anyone who can explain how to do this with autolayout, or why you shouldn't use autolayout.
I've got all my elements in the view and have added constraints to position them correctly on any device.
But when it's run on a 3.5 inch iPhone some of the bottom stuff is cut off and when it's run on a iPhone 6Plus there's a lot of extra space on the bottom.
How could I resize all the elements to look good on all devices?
This is a universal app to run on iPhone and iPad.
I guess you constraint an element as width equals 300...It's very bad for some elements that should fill (or fill percent of) the screen. I suggest you make percentage constraints. For example, make equal width to view, click Edit button and set Multipiler 0.6. It looks like this in storyboard:
make two constraints (trailing and leading for example) and make aspect ratio for your image, maybe this will help you.
i'm back developing IOS after a year and a half. I'm really having difficulty in make use of UIScrollView and auto layout.
I'm developing an application running just in Iphone and portrait orientation.
I have a simple form inside my content view...
label
textField
textField
textField
textField
button
textField
view
imageView
label
The problem is with the width of the contentView's content. The size is been defined for the labels. I would like (And really have to do) o size it according with the screen size.
Here is my constraints of my first text field:
Here is my simulator screen running the app:
how I mentioned before, it seems to get the size according the label and not according the screen size. If I create a constraint of size for the first label, this size change but I would like to get the size dinamically based on screen.
I didn't write any code, I want to do it preferentially using auto layout to understand the concepts of auto layout better.
If someone could help me to solve it... I would be very grateful.
Pin your contentView.width equal to scrollview.width.
Add a constraint to your scroll view's content view child to be the same width as the root-level view.