imageView constraints on iPhone X does not work - imageview

The top constraint of the imageView is set to be 9px from the header but on iPhone X the constraint gets larger. See pictures: grey area between header section and top of image. Any suggestions what might be the problem?
Pics:
Too much space between
Proper 9px space
Note:
- Picture is set to size 1080x1080
- Content mode is set to Aspekt Fill and tried also Scale to fill etc but none will work.
- ViewController consist of nested elements: View- SafeArea-ContentView- View-ImageView. Total constraint top 9px. These are nested inside another VC in a Scrollview element that is placed top:0px from header.
- Constraints set to superview top 0 in and in the headerVC to header top=0

Found a fix. Took away imageView top constraint to superView and Manually ctrl dragged a new constraint from the imageView up to the safe area.

Related

ios 10 autolayout cellview out of view

New to the auto layout world, i can't seem to right align a table relative to its parent content view in the cell. Left aligning works, but when previewing on smaller screens and when running on 6s, the label is not visible/cut off.
according to this thread, the solution was to make sure the tableview was pinned correctly to the parent view controller (0,0,0,0) - but still did not fix my label.
Any help is appreciated.
First of all, add top, left, right and bottom constraints to your tableView.
Also, your label has x position constraint, but how it should lay according to y coordinate? Add label top or bottom or centerVertically constraint.
And what about your redView? Set the needed constraint to it also.

iOS10 storyboard layout issue

We have a table view with prototype cells in a storyboard that work well in iOS 7 to 9. The content of the cells is layed out with AutoLayout.
In iOS 10, the prototype cell does not display its content. The cell is black.
If I run the view debugger and show the clipped content, I see the cell's content being shown. Part of it is within the cell's bounds, part of it outside. Even then, the content's position does not correspond to the layout constraints.
Also, when looking at the view hierarchy on the left hand side of the view debugger, I can see that the cell has no children.
Deleting this line fixed the issue:
expiryDetailsTableViewCell.translatesAutoresizingMaskIntoConstraints = NO;

Drawing node on top of the others in HBox

I am looking for a way to draw a node on top of the neighbouring ones in a HBox. Default behaviour means it is drawn on top of the previous one, but that also means the next one is drawn on top of it. For other containers, one could use the Node.toFront(), but changing the position of the node in the list containing a HBox's children also changes the actual position in the HBox, which is unwanted behaviour in my case. I appreciate any help, thank you.
EDIT:
The overlapping occurs when applying a DropShadow effect on an Ellipse and wrapping them in a StackPane along with a Text. It looks like the effect has a weird interaction with the HBox, as it works as intended without it. After adding the effect, it allocates more horizontal space for the ellipse, but not enough to cover the margins of the effect. Also, when clicking anywhere in the whole right half of the black rectangle, the mouse click is dispatched to the stackPane event handler, not to the rectangle's.
This happens
In VBox and HBox, the Node.toFront() and Node.toBack() functions will change the layout, so they are not usable. If you are using JavaFX 9+,you can use the viewOrder commands to change the rendering order of the Node in its Parent:
Node.getViewOrder()
Node.setViewOrder()
The default value of viewOrder is 0, so setting it to -1 will render it above all others. You can customize this to get specific orders. It also has a CSS property -fx-view-order.

iPhone Autolayout UIText suffocation

I know I can fix this programmatically and I know I could set the text to tighten / scale but I would like to know how to get this text to extend organically to a third line on small screens. How can I accomplish that?
There are a couple of things you need to take care of before your label grows:
Make sure the 'number of lines' field in the attributes inspector is set to zero. Setting it zero allows the label to grow depending upon the content it has.
If the label is in a container view, make sure you haven't specified the height constraint explicitly on the container view. Since the container view should generate its height from its subviews and the subviews will generate their height from the content they have. Its sort of a chain process that goes on if you have a deeper hierarchy.
Make sure there is no sibling view to the container view with an explicit height that might cause your container view to shrink while maintaining its own height. This point may also apply even if your label is not within some container view.
In the image below, the container view(gray one) is bound from three sides allowing it to grow from the bottom.
Below image shows the constraints applied to the content views of the container. The container is driving its height from its content views.
Below I have increased the text of the label from a single line to three lines. At this point the label tries to expand horizontally but since the container view is bind with the super view on both sides the label has only one direction left to increase itself. It increases downwards pushing the textfield and button down and since the button is tied with the bottom of the container view it pulls the container view increasing its height.

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).

Resources