Questions tagged [autolayout]

Auto Layout is a constraint-based, descriptive user interface layout system for OS X and iOS.

The Auto Layout system defines layout constraints for user interface elements. Constraints represent relationships between user interface elements such as “these views line up head to tail,” or “this button should move with this split view subview.” When laying out the user interface, a constraint satisfaction system arranges the elements in a way that most closely meets the constraints. Constraints are objects and can be established in storyboards and XIBs, exposed as outlets, and created or modified in code.

11052 questions
4
votes
1 answer

iOS UiTextField: Text wont center vertically

I am using the Xcode 9 interface builder to design my UI. To maintain an UI which looks the same on every kind of Screen ranging from iPhone to iPad I use high constraints to the superview a lot (for example a UiTextField has a hight constraint to…
MaxWell
  • 43
  • 1
  • 5
4
votes
1 answer

iPhone X: unsafe area doesn't get color of the nearst view

my app is built with custom top bar instead of the UINavigationBar to satisfy some requirements that cannot be done easily with the default UINavigationBar, however, after reading the answers of this question, and changing the 3 constraints of this…
JAHelia
  • 6,934
  • 17
  • 74
  • 134
4
votes
2 answers

Multiline UILabel same width as intrinsic content sized UILabel

I'm trying to align two UILabel's using Auto Layout, where the first label has no set width but using intrinsic content size and the second should be the same width as the first, wrapping text to new lines. Ideally the second label should have…
Aleksander
  • 2,735
  • 5
  • 34
  • 57
4
votes
4 answers

How to change tableview cell height according to label text swift?

Using a UITableView in Swift, could someone please help me automatically change the height of the cell based on the label, picture, and description please? I want to dynamically change the cell size as the label text increases. i have already…
xeb
  • 191
  • 1
  • 4
  • 12
4
votes
1 answer

There is no SafeArea option for xib files

I'm trying to update my apps for the iPhoneX and there is no 'SafeArea' guides. Are they only in Storyboards, not individual nibs?
Buyin Brian
  • 2,781
  • 2
  • 28
  • 48
4
votes
3 answers

Xcode Interface Builder: Make a view's center X equal to third of its superview

I have a two views I'd like to place in a way that they are equally spaced horizontally. I'd like to define thier Center X so that they are the third and two-thirds of the width of the superview but I have found no constraint setting that allows you…
Zoltán Matók
  • 3,923
  • 2
  • 33
  • 64
4
votes
1 answer

TopLayoutGuide and BottomLayoutGuide Deprecated in iOS 11

UIViewController's topLayoutGuide and bottomLayoutGuide are deprecated in iOS 11. What should be the replacement?
James Kuang
  • 10,710
  • 4
  • 28
  • 38
4
votes
1 answer

Container View Controller how to find and provide size of child view controller in sizeForChildContentContainer

When a change in size happens for a View Controller (VC) (e.g. on device rotation), we all know this method is called: -(void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id)coordinator The size parameter is the size of…
Tumata
  • 1,507
  • 1
  • 11
  • 14
4
votes
1 answer

Could not find relevant edges for attributes

I get the following error: Could not resolve symbolic constant for constraint, because: Could not find relevant edges for attributes: centerX and centerX. Use a symbolic breakpoint at …
Nef10
  • 926
  • 2
  • 16
  • 26
4
votes
1 answer

Changing constraint multiplier using traits

I have several objects with a width of at least 75% of the screen width. The issue is that they do not look as good on iPads or landscape mode. I want to change the "75%" for different traits but couldn't figure out how. I've looked at the details…
Nimrod Shai
  • 1,149
  • 13
  • 26
4
votes
1 answer

Dynamic Height of UITableView

How to get the Dynamic Height Of UITableView with Constraints. It will increase the UITableView Height depending upon Number of row without adding Scrollbar in table. I'm facing problem in adding the TableView in UIViewController and Height of…
Anand Verma
  • 572
  • 1
  • 6
  • 11
4
votes
3 answers

Is it possible to have overlapping views with auto layout?

I'm trying to have to views overlap as shown in the picture below, but I couldn't figure out how would I go about doing it with auto layout. I tried doing the bottom view programmatically, and it worked fine except for the button which I had laid…
Ahmed Al Abdulaal
  • 270
  • 1
  • 3
  • 16
4
votes
1 answer

Is there is a way to create constraint greater than or equal relation through code

I'm working on expandable table cell, and my algorithm is follow: I create two views. Create the height constraint of second view, drag it as IBOutlet to my cell. When cell is selected change status of selected cell. class ExpandableCell:…
dand1
  • 371
  • 2
  • 8
  • 22
4
votes
1 answer

Programmatically adding views to a UIStackView

I am attempting to add two dynamic UILabels to a UIStackLabel. The goal is center the two labels horizontally in the middle of the view. The two UILabels are: var nameLabel: UILabel! var ageLabel: UILabel! And the UIStackView is: var…
daspianist
  • 5,336
  • 8
  • 50
  • 94
4
votes
2 answers

How to center horizontally 2 or more UIViews inside a UIView container using autolayout programmatically in Swift 3.0

I'm trying to center 2 or more UIViews horizontally inside a UIView e.g. | [UIView1] [UIView2] | | [UIView1] [UIView2] [UIView3] | or | [UIView1] [UIView2] [UIView3] [UIView4] | I'm adding these…
Black Sheep
  • 1,665
  • 1
  • 22
  • 32