How to Manage Equal width of Views - autolayout

I have to design a screen with contain 3 views of equal width.& every view has a remove Button to remove particular view.
when i tap on first remove Button than other two views have to equal with along to base View.
How can i manage constraints for this Situation.
Please anyone tell me how can i manage.
Thanks

Probably the easiest method is to use a UIStackView, with Distribution set to Fill Equally.
When you start, the 3 views will each take 1/3 of the width of the Stack View. On button tap, you can use .removeArrangedSubview() and the Stack View will automatically re-size the remaining two views to each take up 1/2 of the width.

Related

CSS transition animation with tiles layout is it possible to achieve?

I am trying to create a specific solution for weeks now and I have tried many things but I am just not sure if it is possible at all to achieve. I need your opinions and point me in direction o a correct approach. Following what I am trying to create:
Initially there is a tile layout in which a certain number of cards (say 12) are placed in 4x3 grid:
Now, if user clicks on a tile (Box 3), the state changes to following:
Selected tile is expanded and other tiles get aligned one below another on the right side:
Challenge is that I want to create a transition from every tile's initial state to the state where every tile is aligned one below another on the right. At the same time, when a tile is clicked it is expanded in place.
Note - there are no sudden change in positions, no reload of page and preferably no JS (I wanted to write a CSS-only solution). Everything smoothly animates to new position. From the second screen if a different tile is selected (from right), then the expanded item will shrink and go in to the right hand stack while the selected item will expand and take place of the currently expanded (B3).
If you could just point me to correct direction it would be great help.
thanks.
You should check css flexbox.
Using the "order" proprety, you could asign order of every box from 2 to 8,
and each time a box is selected, you change it's order to 1 and you also change its size and colour.
However, I don't think you can use 'click' actions with css only.
I would recommend using JS for what you are trying to achieve.
Hope it helps

Is possible to do a flex layout with Qt?

I want to make something like a gridlayout but the layout must decide how many elements can be fitted in a row, and when the row is full continue with the next row.
QtGridLayout also fixes the columns width.
I want to something like this (this pictures was manually organised in Horizontals and verticals grids)
When the image size changes one of the buttons goes to first row.
((In this compositions both images looks with the same size, but actually second one is wider than first one).
Some one answer this question but remove it, so the credits are for my unknown friend.
Qt have an example named Flow Layout Example for a widget based form and another for Graphics View widget.

Resizing the superview according to the subviews

I have 3 subviews(UILabel, UIImageview, UIButton) to be laid out on a container view. All the subviews are laid out using visual format language (VFL). The subview have padding from the leading , top edges etc. The content of the subview are dynamic so their sizes changes all the time. i want to resize the superview(container view) to exactly fit all the subviews. Is this possible by auto layout? i have seen some of the link here which suggest intrinsic size which i am not able to understand. can someone suggest a better way to achieve this.
Yes, it's possible. If you plan to resize the superview according to subview content, then intrinsic content size is the way to go.
The ever excellent Ray Wenderlich site has a tutorial that covers this well. It's Beginning Auto Layout in iOS 6: Part 2/2:
Intrinsic Content Size
Before Auto Layout, you always had to tell buttons and other controls
how big they should be, either by setting their frame or bounds
properties or by resizing them in Interface Builder. But it turns out
that most controls are perfectly capable of determining how much space
they need, based on their content.
A label knows how wide and tall it is because it knows the length of
the text that has been set on it, as well as the font size for that
text. Likewise for a button, which might combine the text with a
background image and some padding for the rounded corners.
The same is true for segmented controls, progress bars, and most other
controls, although some may only have a predetermined height but an
unknown width.
This is known as the intrinsic content size, and it is an important
concept in Auto Layout. You have already seen it in action with the
buttons. Auto Layout asks your controls how big they need to be and
lays out the screen based on that information.
It is possible.
In my case, I wanted to give rounded corners to segmented control. For that, I embedded segmented control in UIView. Now I was required to resize that container view as per size of segmented control.
I gave only following constraint and everything was taken care itself.
(1) Chose container view and give it X and Y constraints.
Leading space to Super view.
Top space to Super view.
(2) Chose container view and give Leading | Trailing | Top | Bottom constraint.
Leading space to segmented control.
Top space to segmented control.
Trailing space to segmented control.
Bottom space to segmented control.
(3) Chose segmented control and give it Height and Width constraints.
Height : 30 // Whatever
Width : 250 // Whatever
Now if I change the height and width of my segmented control, it automatically adjust container view's size (super-view of segmented control).

get TileGroup to autoresize columns

Not sure if I am doing this the best way but I want to create a mobile app that has a home menu screen much like the facebook iphone application(with out all the fancy button moves etc). The FB app has a 3X3 set of buttons that allow you to access things like news feed or friends.
In order to keep my layout consistent across different device screens I was trying to user the TileGroup with an image as a button for each tile.
but while I can specify the tilegroup to use 100% width and height and set the number of rows and columns to 3. It does not appear to autosize the height of the rows and columns to fit the screen. and it won't let me specify the with/height as a percentage.
so my question is firstly am I doing the right thing or is there a better way to lay it out. And if I am doing the right thing, then how do I get the columns to auto size
Thanks in advance
JaChNo
Try Using this. apply the following u may get what u needed
<s:TileGroup id="tile"
columnCount="3"
columnWidth="{tile.width / tile.columnCount}"
rowCount="3"
rowHeight="{tile.height / tile.rowCount}"
/>

Check if control is on screen

How do I check if a control/DisplayObject is on screen? This means it is displayed on screen so no scrolling needs to be done.
Example: I have several controls on a form. The size of the form exceeds the screen length/width. As a result I need scrollbars. How do I check if a control is on screen?
This is a less elegant solution, but if no one else answers, you can try to do this:
Check X and Y (or just Y if you are interested in height) of the component you want to verify is on-screen or off-screen.
Then compare that to the total height of the application or container of the component.

Resources