Margin space UITableView (Swift) - ios

I want to show margin space left and right in UITableView look like images. I used Xcode 7.3.1 and deployment target is 7.0. Please help me! Thanks very much.

You have to add one UIView into cell's contentview and than give constraints to it like below ...
Note: Don't forget to add background color to cell's contentview to see the effect.

Add left and right constraints as shown in pic below. You can change the margin to the value that you need. Dark red (vs dotted red) connectors says the constraints are selected. Click on "Add 2 constraints" to add it.

Related

An image view on an Image View xcode

I'm developing an app using Xcode 8.1 and and swift 3.0.
Using storyboard I've expanded an image view to take up the whole view and set a picture to it to be used as a background image (using self.view.background doesn't give the image the same layout).
This works. I have defined the constraints for it plus added 2 textboxes and a button that also have constraints.
Now I try to add a new image on top of the background image, but then I cannot define the constraints for the front-most image view. I get something like this with two errors telling me to define the constraints but when I do nothing happens.
The way it looks you as per the screenshot, you should just give the padding (spacing to nearest neighbour) for left , right and top in your storyboard.
If there are any warnings just set the current constraints to supersede other views. This can be achieved by selecting the warning and then update constraints and check the box apply to all views in container. It should work.
You need to pin the imageView, what constraints have you set so far?
Just set the constraints for the front image view (as on the your screenshot as well). I don't see any problems.
have you set below constrains
1. Top Layout
2. Bottom layout
3. Leading
4. trailiing
5. height
or
horizontal in center
vertical in center

How to adjust this view with constraints

I'm totally new to Swift and in general, to iOS development. I just want to center a rounded profile picture with a table view above. In iPhone 5 it looks centered, but in iPhone 6 and 7 it look aligned to left, I don't know how to fix with constraints, I'm a little bit confuse.
This is my constraint tree:
How it looks storyboard for iPhone5
How it looks storyboard for iPhone 6/7
This is how it looks in emulator with iPhone 6
Can you guys help me to figure out what I'm doing wrong?
Thanks in advance!
Cheers.
It looks like you've set the width and height of your image view to hard-coded values, which will result in it looking centred for some views, but not all.
Reset your constraints, then set your distance from each of the four sides to zero. That'll centre your image!
Go to Editor -> Resolve Auto Layout Issues -> Reset to Suggested Constraints...
...then click that button down the bottom right and set each of your four sides' distances to zero.
Make sure you set Update Frames to "All Frames in Container" before clicking "Add 4 Constraints".
Try setting horizontal constrain between your My UI Image View and HeaderView. You can set centre hozintal with HeaderView.
Go to button down the bottom right and set centre vertical and centre horizontal to your My UI Image View.
Hope it helps. Happy Coding!!

How to center TextField using Xcode constraints?

I am new to iOS and am trying to align these TextFields in iOS. Below is how I would like it to look on an iPhone 7.
However, on the iPhone 7 Plus, the TextField shifts to the left of the center, despite my constraints.
Why is this? I have a constraint that aligns them to the Center, as seen on the right part of the screenshot.
It is very simple!! Just follow below steps,
Open you .xib or .storyboard file
Select view you have to add constraint
Click on align button at the right - bottom corner
Set horizontally in container constraint 0
Then press add constraints button
You can add any constraints to any view by following these steps
You just have to seth trailing and leading space fixed means both left
and right indicators should be red as shown in the screenshot.
For more details see the screenshots:
It will remain fixed from left and right in all the screens.
in your case is important set the width constraint.
However you can use trailing and leading constraints, in this way you will not need to set a defined width for your textfield and the position is correct for all type of devices.
If you want design like this so you have to take UITableview then take UITextfield for every cell beacuse you use every cell as view so easily manage all textfield and constraint. And also easily scrolling if device is display small.

How can I make UITextField always centered on the screen?

I'm making an app in which I add people to a list by using a modal VC, that currently has only three text fields.
Problem:
This is what I see in the interface builder, inside my Main.storyboard file:
I'm running Xcode version 6.2 (6C131e) and the app I'm making will be for iPod touch only, so I disabled auto-size classes. I'm expecting those text fields to be at the center of the screen (same distance from text field lateral border to screen edges). Instead I get this on the simulator:
Question:
How can I set an equal distance for both the sides of text fields? Any resource like tutorials, examples, guides are appreciated, because I am a very beginner in iOS programming. If this can be done with interface builder for me is better then programmatically.
As simple as this:
In the Align menu from the bottom of interface builder if you set this constraint to 0 it will be the center of the view
Select First Textfield
Goto Pin-> Uncheck constraints to Margin-> Select Top,Left,right constraints with default value(or change if want ex. 16 left,right,30 top).
For Second and Third Textfield
Goto Pin->Uncheck constraints to Margin->Select Top,Left,right constraints
If you are not using Autolayout then the default Autoresizing property should be
Change the Autoresizing property to this :
Check this question : Any other method to resize views, other than Auto-layout
I just take horizontally as example. You have two ways to make it in the centre.
1. Make leading space equals trailing space.
Make the textfield center horizontally in container view.
I recommend you can study with raywenderlich tutorial.
http://www.raywenderlich.com/50317/beginning-auto-layout-tutorial-in-ios-7-part-1

iOS - Constraints "Margins" warning - UIView inside UITableViewCell

I'm having problem with using constraints inside a UITableViewCell. I want to place a UIView inside a UITableViewCell just to use the UIView as a frame, so the UITableViewCell looks like a Cell with borders.
The problem is as soon I drop the UIView inside the Cell and click "Add missing constraints", I get a warning: "Layout attributes relative to the layout margin on iOS versions prior to 8.0".
I looked for a solution but all the solutions here did not work. When I try to uncheck "Relative to margin" option, like in the top answer to the linked question,the warnings are gone but the UIView covers the full cell. But I want small borders around the UIView.
Here are some photos how it's looking right now:
Before I uncheck the "Relative to margin" option in my constraints (Thats how it should look like!) :
And after I unchecked them:
Can someone help me out? Thanks
EDIT
Thanks to Kris Gellci. I found the solution. After I unchecked the margins box, I had to reset the vertical and horizontal Space constraints. Now it works fine.
Click on each constraint and make sure that none of them are have the "relative to margin" set on either "First Item" or "Second Item". Unselecting the relative to margin will then require you to reset the constant on the constraint. Attached are some screen shots for reference:

Resources