swift - arrange buttons across many screens - swift

I develop test app with swift ,
I need way to arrange first row in first screen to first row in second screen
to make all button across application look similar
my tries :
match X,Y value , width , height

Do you use Auto Layout ?
You can achieve that by
set vertical space between the top edge and your title
set horizontal alignment of title to be center of the view
set vertical space between title and the first item in the row
set leading margin of the first item in the first row
set horizontal alignment of all following items to be center of the first item

Related

How can I set a bottom position on a horizontally scrollbar in Ag Grid?

I am trying to position the horizontally scrollbar on a bottom position when some field of the table is changed.I tried with : Scrolling Ag Grid using ensureIndexVisible()
But as least I know it is only for vertical scrollbars
There is also a method ensureColumnVisible(colId), from docs (in the same section you are refering to):
Ensures the column is visible, scrolling the table if needed.

Random table view cell height is not working perfectly

I am designing a chat app in which I am using the UITableViewAutomaticDimension property of table view when I am setting the label lines to 6 then all cells height is according to the text which label contains but when I increase the number of lines for label then some cells have extra height. Even when scrolling it then cell height again changed.You can check the image so that you can understand it easily thanks.
You need to give label constraints from top and bottom, rather than center vertically.
Give vertical content hugging priority

Left aligned horizontal stackview and top aligned vertical stackview

I have two StackView, one of which is horizontal and another vertical.
For the horizontal StackView, I want the items to be aligned to the left and grow toward the right.
For the vertical StackView, I want the items to be aligned to the top and grow downward. For example the position of the top item would never change but the stackview expands down if another item is added.
I'm having trouble accomplishing this, for example with my horizontal StackView, if I have two items 40x40, they will example the entire width of screen for some reason and I've tried a whole slew of different variations of distribution, alignment and constraints.
For my vertical StackView, if I add two items, my first item will move up and the second item will go underneath, so the center is now between the two instead of the first item staying still and the second going underneath it.
I can't figure out what I'm doing wrong here and how to just get StackViews where the first item is sized correctly, in place, and future items follow it, expanding either rightwards or downwards.
What you need is for Vertical
1- Drag a UIStackView with top , leading and trailing constraints to the superView
2- Drag any view inside it and give it a height constraint
for Horizontal
1- Drag a UIStackView with top , leading and height constraints to the superView
2- Drag any view inside it and give it a width constraint
Note : Make distribution set to fill

Storyboard labels constraints

I have 4 labels on my storyboard, aligned at baseline and with fixed distance between them.
Each label can have different values at runtime, and I would like that the group of these 4 labels is horizontally centered.
Didn't succeed to fix it !
I tried to put them in a view and center the view, but it doesn't work either.
Tried also to play with priorities, but didn't't succeed either...
Is it possible to achieve that in the storyboard ?
You can do this by putting your 4 labels inside of another view. Add the following constraints:
Set fixed distance constraints between the labels (3 constraints).
Set constraints to align the baselines of the labels (3 constraints).
Set a leading constraint from the leftmost label to the containing view. Set the constant to 0.
Set a trailing constraint from the rightmost label to the containing view. Set the constant to 0.
Set a constraint for the height of the view.
Set a constraint from the top of the left label to the top of its containing view.
Set a constraint to center the view horizontally.
Set a constraint to position the view vertically.
The width of the view will be determined by the intrinsic sizes of the labels plus the sizes of the distances in #1. This width will change as the contents of the labels changes, and the view will keep the group centered.
You can use a Stack View for this:
In the 'Attribute Inspector' you can set for example that each text field has an equal width and a spacing of 5 points between them:
You can then use your Stack View to center horizontally like your normally would do.

make four buttons width to fit for all screen size in swift

I am doing a sample project with size class and autolayout in swift.I have four buttons on top of the screen.How to set same width for all buttons with one pixel gap between them and make them fit for all screen size.
thanks in advance
The trick here is to make the button widths variable, but the same for all buttons. This can be accomplished like this:
Place the four buttons
Set the left margin constraint from the leftmost button
Set the right margin constraint from the rightmost button
Set horziontal distance constraints between the buttons to 1
Set the width constraints for all buttons to >= 10 (or any other
value, this makes the width variable)
Set equal width constraints on all buttons (ctrl-drag from one button to the next and choose equal width. Repeat that for all buttons)