How to create any UIObject with millimeter measurements? - ios

I need to do the measurements with millimeter instead of points or pixels. I want to add an image has a fixed size but in mm. Anyone can help me please? It is like when you have to draw a ruler, how to calculate the 1 mm between the tow lines on screen? it is really confusing and I couldn't figure it out.

1 Apple point is 0.352778 mm(s), you can use this site to do the conversion: https://www.conversionunites.com/converter-points-to-mm.

Related

Offset two child-charts within a VictoryChart

I have a boxplot and a scatterplot within a VictoryChart and want them shifted a number of pixels in the non-domain axis.
My current code and resulting chart are here: https://codesandbox.io/s/beautiful-violet-opclp?file=/index.js
Now I want the red triangle to be placed a bit higher, so about 15 pixels in the y-direction upwards. I tried padding, domainPadding, dx, dy, but nothing works really.
Any hints are appreciated!
By creating a custom point, the actual position can be set. See https://codesandbox.io/s/focused-lederberg-i8ddx?file=/index.js

Changing text adjustment in UIView using swift

I've been trying to create my app and something is bugging me very much,
I have images of what I am trying to achieve:
1)
2 )
number 1 shows what I am trying to do, the letters are "squeezed" together making the text appear tighter with a short width even though the letter sizing is big.
number 2 shows my attempt to achieve this, I tried multiple different ways to get that same look but failed for hours, does anyone have any suggestions or know how to make the text look like that in the first picture?
I appreciate any help, thank you!
The only way how to do it AFAIK is to use transform on UILabel, like this:
let widthTransform = 0.8 // Shrink label to 80% of its width
label.layer.transform = CATransform3DMakeScale(widthTransform, 1.0, 1.0);
Hope it helps!
Note* that transform work for about 30% of decrease (even less imo), then it just starts to look very bad. You can also change text spacing, but if you calculate it dynamically, you could end up with negative one and that looks terrible. The easiest way really is then just change of the design :)
Options:
You can decrease character spacing like in this answer
and increase font size.
Having fun with transformation on layer is really awful idea, as later you won't be able to get the height of text etc -> just everything will be working wrong.
You can also just use different font.

highcharts move a point using pixels

I have the following chart as an example. I would like to move the points over B such that 1% is over the orange column, and the 2% is over the blue column. Is this possible?
http://jsfiddle.net/0m3208qj/4/
code
The points are positioned according to the y value. So if you need increae position of it, you need to prepare another y values.
I managed to do this, but in a complicated way. I had to split the points into two series, use pointPlacement to move them to the correct place, and then use the renderer to draw custom lines!
Here is an example: http://jsfiddle.net/8datkr4m/
Code

multiple points with UIBezierPath in UIView , what formula to apply?

I'm working on an app on IOS with Xcode (objective-c)
Here is the problem :
I'm working on a new way to show some statistics based on some frequency in a day, every hours.
Here is what i'm trying to achieve:
What you see is sort of clock on a 24 hour basis (top = 0 o'clock, each 15 degrees is an hour)
Each hour i have a distance from the center of the circle.
Those values are known, what I have hard time to achieve, is the curves themselves !
Indeed, In an UIView, I think i need to use UIBezierPath to draw the curves, but i have no clue on what formula I need to apply in order to make the graph passing through all the points ?
I hope I am clear with this question. Don't hesitate to ask me to clarify myself !
Thanks again, and see ya later !

amount of rect intersection?

i am trying to check the degree of overlap between 2 CGPaths.
the easiest way i have come up with is get the percentage of the overlap between the bounding CGRects. I know this will fail when different paths occupy similar bounds. but oh well, if you know of a better way ... please help.
anyway, the current question regards calculating the percentage overlap between the rects.
i see the CGRectIntersection function to obtain the rectangle of intersection. I can calculate the area of this rect, but there doesn't seem to be an easy way to get the area of the non-intersected regions. any ideas? would subtracting that area from the area of the rectUnion make sense? if i understand rectUnion correctly, if the union and the intersection are the same size, they completely overlap?
Not quite understanding, I think. Isn't the "non-intersecting region" of a CGRect A with another one B just A's area minus the intersecting region? Or more to the point, isn't the percentage overlap just equal to the intersecting area divided by the combined total area:
Area(A ^ B)/(Area(A) + Area(B) - Area(A^B))
(BTW, I don't think you want to deal with RectUnion as that potentially has a huge amount of space in neither A or B. )
Oh, and on your original question, that's beyond my graphics ability, but the basic technique seems to be to draw both Paths in a graphic context (maybe with an XOR) and see which pixels are still left on. There seems to be some code pointing the way here: Clipping CGPath to a CGRect

Resources