Questions tagged [ios-autolayout]

In iOS, Auto Layout dynamically calculates the size and position of all the views in your view hierarchy, based on constraints placed on those views.

In iOS, Auto Layout dynamically calculates the size and position of all the views in your view hierarchy, based on constraints placed on those views.

More info

1049 questions
4
votes
2 answers

When do I have to use Priority in iOS AutoLayout?

Using iOS AutoLayout you will do something like: self.view.addConstraint(NSLayoutConstraint(item: label, attribute: .Width, relatedBy: .Equal, toItem: self.view, attribute: .Width, multiplier: 0.3, constant: 0)) You can…
user4788711
4
votes
1 answer

UIButton with edge inset does not follow content compression resistance property

Content hugging priority =250 content compression resistance priority =750 width =70 priority =500 (for normal text) left and right edge inset =3 if I set left and right edge inset = 0 and rest of the things as it is
saurabh
  • 530
  • 1
  • 8
  • 22
4
votes
1 answer

Autolayout detect when UIView got the frame

I have UIView that has auto layout constraints. I create it with frame CGRectZero. So I don't the real size. It will depend on superview. But I want to know when my view get a frame that I can use for my calculation.
Matrosov Oleksandr
  • 25,505
  • 44
  • 151
  • 277
4
votes
2 answers

How do I programatically use AutoLayout to set a UIView to the same width as its SuperView?

I have a simple UIView that I want to make the same width as the containing View's width. I want to do this programatically. I can add a constraint in the containing View that makes the SubView's Width equal to the width of container. The C# is…
Pat Long - Munkii Yebee
  • 3,592
  • 2
  • 34
  • 68
4
votes
4 answers

Re-enable UITextView scrolling after it expands, with AutoLayout, to a specified height

I understand there are some similar posts but they don't seem to work for me. I have a uitextview that I want to behave similar to messenging apps. I used autolayouts and [textview setScrollEnabled:NO] to allow the uitextview to expand dynamically…
marshy101
  • 594
  • 7
  • 19
4
votes
1 answer

Dynamic height of UITableViewCell with variable number of subviews with autoLayout

I am in a situation where I want to have UITableViewCells which have variable number of subviews depending on the data. Obviously this would lead to dynamic height of each cell. I researched and found a very nice post at Using Auto Layout in…
tarun_sharma
  • 761
  • 5
  • 22
3
votes
2 answers

How to set topAnchor constraint relative to the superview height

I have two views: toastView and view. toastView is subview of view. I want to position toastView on the y axis by 80% of view height. How can I do this using constants in the code? I assumed that there is a method like: [toastView.topAnchor…
3
votes
2 answers

How do I align ImageView to the bottom of ScrollView programmatically?

I am trying to align a background image to the bottom of a scroll view that fits the screen, programmatically using Autolayout. Ideally, I want the image to be always aligned at the bottom of the scroll view. When the content of the scroll view goes…
Samuel Kith
  • 109
  • 12
3
votes
1 answer

Prevent UIStackView from compressing UITableView

I am adding a UITableView into vertical UIStackView. That vertical UIStackView is within a UIScrollView. However the table is not displaying unless I force an explicit Height constraint on it which I obviously don't want to do. According to this SO…
Pat Long - Munkii Yebee
  • 3,592
  • 2
  • 34
  • 68
3
votes
3 answers

Have button in UIToolbar cover full height below iPhone X Home Indicator

I have a UIToolbar at the bottom of the screen that contains three buttons, all with different background colors. I use Auto Layout and constrained the toolbar to the bottom layout guide (I have to support iOS 8, so no Safe Area Layout Guides) so…
Mark
  • 6,647
  • 1
  • 45
  • 88
3
votes
1 answer

UITableViewCell height not dynamic when constrained to UIStackview containing multi-line UILabels

I have a tableview cell that contains a UIStackView. The stack view contains two labels that could be multiple lines and another stackview at the bottom. This is how the cell should appear, but with more margin. This has a 15 point constraint on the…
yamski
  • 471
  • 4
  • 14
3
votes
1 answer

where to update constraint in view controller life cycle

I would like to update constraitn constants and multiplier and I would like to update these constraints in right view controller life cycle event loadView viewDidLoad viewWillAppear viewWillLayoutSubviews viewDidLayoutSubviews viewDidAppear There…
3
votes
1 answer

why Scrollview and child view size is inconsistent sometimes

I have a scrollview and a child view. Child view size increases dynamically depending on its content. I am programatically changing the child view height via constraint and at the same time I am incrementing scrollview content size . so the…
Dan Ram
  • 171
  • 1
  • 14
3
votes
1 answer

Why these layout issues occur when debugging view hierarchy while the UI layout in simulator is OK

I use visual format to layout subviews in cell like this: contentView.addSubview(accountLabel) contentView.addSubview(contentLabel) contentView.addSubview(timeLabel) let views: [String : Any] = [ "accountLabel": accountLabel, …
a_tuo
  • 651
  • 7
  • 23
3
votes
1 answer

Blank space coming between keyboard and UIVew in iOS

I have a tab bar controller-based application and I am using IQKeyboardManager to handle form-like stuff. Step 1: Tab bar controller with bottom a UITextView inside a UIView. Check Image 1. Step2: When I click on UITextView, the keyboard appears…