Vertical or diagonal scrolling on UIScrollView - ios4

In my case the method scrollViewDidEndDecelerating can detect just horizontal scrolling in UIScrollView and i want to know how to detect diagonal or vertical scrolling.

To detect the direction of the scroll in, say, scrollViewDidScroll:, look at how scrollView.contentOffset.x (horizontal) and scrollView.contentOffset.y (vertical) have changed from their prior values. If they've both changed, then it's a diagonal scroll.

Related

Scale down an image dynamically

In my SVG picture there are some text labels that are displayed dynamically in top part of the image. In some cases (i.e. smaller screen size, bigger font size), they partially disappear outside the vievBox (like if overflow: hidden; was set) - see the picture (the long word in the middle is the overflowing label).
My idea is to scale down the image so that the labels are visible. How to achieve this?
In my case, I had quite wide bottom margin, so I could afford moving the whole image down to uncover the top part.
Final solution was wrapping the whole image with <g transform="translate(0,10)">.
The first value refers to left-right movement, the other one to up-down (positive values move the image down, negative - up).

Text in Ellipses JavaFX

I created a custom venn chart for two sets an their intersection in JavaFX.
Now I want to show the number of elements in this sets like in the following picture:
The sets are ellipses and I used masks to give the intersection a different color.
Now I want to show the number with size and position related to the available space so that the numbers are always inside the according area.
The width for the text element is easy to calculate, but I don't know how to get available height for the text elements.
Maybe it could be helpful to have the pixels of the ellipses as path, but I have no idea to how I can get this.
Does anyone know how to implement that?
Edit:
I developed an algorithm to find the size of a rectangle, which fits in the required areas of the ellipses. The text are scaled to the size of the rectangle and it works, but now I have another problem.
I need to center the scaled text in the rectangle an I used a StackPane for that. But I can't position the StackPane in the chart parent. If I set the layoutX and layoutY the bounds in parent are different.
For example: stackPane with text = sp;
sp.setLayoutY(122.1662320906945);
The Result for getBoundsInParent().getMinY() is 97.16622924804688;
How can I set the StackPane position, if I use it in a chart class as chart children?

Extend two colors bars across full width of browser?

I have two boxes filled with colors, a green one on the left, and gray one on the right. They go right up against each other in the middle of the screen, and I would like each one to extend the width of the browser, so the green one extends all the way to the left, and the gray one extends all the way to the right, no matter how wide the browser gets. How can I do this?
the width property supports percentage values, which are relative to the size of the window it exists in.
See:
http://learnlayout.com/percent.html
http://www.w3schools.com/cssref/pr_dim_width.asp

Top vertical align in line-height (or vertical spacing without line-height)

I have a multi-line title side by side to an icon. I would like to keep the line-height of that title at about 1.6 . If I do so though, the text does not align on top because it stays vertically centered to the line. The result is that the top of the icon is not aligned with the top of the text. If I use line-height 1 the problem does not occur because the middle vertical alignment of a text in a line of the same size is the same as the top alignment.
You can see what I mean in this code pen.
Any idea?
You can add a negative top margin to your title.
Defining both your font size and the margin in em will allow you to achieve alignment regardless of what font size is inherited.

Vertical Spacer doesn't stretch past sizeHint in Form layout

I am trying to design a form in which some elements stay at the bottom of the Form Layout when the window size is increased, and others stay at the top. Using a Vertical Spacer between the top and bottom elements almost works, but the Vertical Spacer only stretches up to the Height value of its SizeHint (see screenshots below).
Simply increasing the SizeHint to some large has the unwanted side effect that the preferred size of the overall window then also becomes very large, so the "Adjust Size (Ctrl+J)" command makes the window unacceptably large.
If I use a Vertical Layout instead of a Form Layout, the stretcher behaves as I expect it to, increasing indefinitely and respecting the SizeHint when using "Adjust Size", but of course I lose the behaviour of the form layout (the alignment of the TextLabels).
What can I do to make the Vertical Spacer stretch past its SizeHint in a Form Layout?
Use multiple layouts, not only one.
Set vertical layout for your window.
Add horizontal layout, fill it with QLabel and QLineEdit. Add Vertical Spacer.
Add another horizontal layout, fill it with QLabel and QLineEdit.
Add horizontal layout, fill it with Vertical Spacer and two QPushButtons.
If I understood you correctly, you should get what you wanted :)
Another way is to use QGridLayout.
Set QLabels to 0,0 and 1,0
Set QPushButtons to 2,1 and 2,2
Set QLineEdits to 0,1 and 1,1
Drag QLineEdits so that they span from column 1 to column 2
And Vertical Spacer between row 0 and 1.

Resources