I have added a view in my app. I want the view to look equal on all the devices. So I have applied below constraints. The width of iPhone 4 & iPad looks similar so I want to know it is happening. Below are my constraints.
In case of iPhone 5,6,6+ the width is looks similar
Constraints are as follows
Related
I'm creating a simple app that includes a table view using Swift 5 and Xcode 11. Inside the table view(which, by the way, is fixed into landscape), there is a button on the right of the tableview cells and an image view with fixed constraints, size, and width on the left. Everything has been working out pretty well for my app, until I noticed that the image view would kind of 'disappear' if I changed the device to, for example, iPhone 5s, 4s, or even iPhone Pro(I'm testing with iPhone 11 Pro Max).
This is when the device is iPhone 11 Pro Max:
11 Pro Max
This is when the device is iPhone 11 Pro: 11 Pro
And here are my constraints for my image view: Constraints
Any help is appreciated
P.S. Ignore the image view that says 'img'
After seeing both of the screen shots and the constraints I see what is the issue here.
It's the way you have applied the trailing constraint for the image which in your case is 663 (Should not be fixed). What you can try is Give width constraint to the image view and then change the trailing constraint something like below
This should help you.
Also what you have to take care of moving forward is the constraints you choose to apply coz that is the most important thing while desigining Responsive UI
Happy Coding.
right Constraint should be negative,for example,
img.snp.right = view.right - 20
I am new to Xcode, and have been trying to figure out how to use AutoLayout and constraints. Long story short, after I hit 'add missing constraints' the Iphone 7 screen looks just as I intended, but both the Iphone 7 plus and Iphone SE screens look completely screwed up. What can I do to fix this so that every screen looks like the Iphone 7?
Iphone 7
Example Iphone SE (screwed up)
add missing constrains option means: adds the constraints needed to have a nonambiguous layout. may not work well for all iOS devices, and may not work well for device's rotation changes or view size changes, so, check view's constrains in size inspector panel
for more info:check Apple's auto layout guide
I have developed my App on XCODE 8 which by default removes iPhone 4 emulator and I didn't notice that until I finished my app, and I used Auto layout to make the UI fits all iPhone screens and that what happened (the layout was good on iPhone 7,6,5) the problem is when I additionally installed iPhone 4 emulator I found that the layout is totally missed up and unreadable/usable.
So what options do I have to solve this and make it fit the iPhone 4 screen too with Auto-Layout with missing up the other sizes ?
Here is screen shot of my Login screen on iPhone 6 (4.7") vs iPhone 4 (3.5")
You must always give constraints with respect to other alternative buttons or a view, it should not be hard coded. Try making views programatically, it will be more easy and helpful to you.
It seems like your constraint is set to have a fixed distance related to the top of your screen. So when the screen height get smaller, your views are pushed out of the screen. So to better adjust views position, you can have your views to be related to vertical center. Say your login box is in both horizontal and vertical center, not metter you are using iphone 6 or 4, you should always see your login box.
I"m encountering a constraint issue where the middle UIView in between two UIViews, one at the top and one at the bottom, is getting squeezed on a 3.5 inch iPhone screen (iPhone 4S). I'm not sure what's wrong with my constraints but here is what it looks like on iPhone 4S...
Here's what it's supposed to look like (iPhone 6)...
And finally here are the constraints...
Tell me if anymore information is needed. Thanks!
I'm attempting to build a view (iPhone only, portrait view only) using adaptive layout. It should all be on a single screen (ideally no scrolling). I've managed to get it working (reasonably) for the iPhone 5 - 6+. However, my issue comes with the 4s.
I'd like, on the iPhone 4s to have the center image go away, which I thought I could use size classes, but it doesn't seem so for the various iPhones in portrait mode (only if I switch orientation).
Additionally, I'd like there to be more padding between all the elements on the 6+ while spacing remains the same on the 5 and 6.
No matter what sizes all iPhone in portrait mode is regular height compact width so size class won't help you here.
To change padding constraint
make the ones you want to change IBOutlets
and in viewDidLoad for example change the NSLayoutConstraint's constant value based on screen height.
For iPhone 4S you can
hide the center imageView
deactivateConstraints all it's constraints
and activate new constraint between the view above imageView and below imageView if needed