Question

I'd like to display in (real world) mm/cm the distance (only on the y axis) between 2 images that can travel on the y axis. I've thought long and hard about this but can't think of a reasonable way to this given my inexperience (go easy on me! I'm new to development). If someone could help me out, that would be fantastic.

Was it helpful?

Solution

1 cm = 47 pixels and it is easy to find distance between 2 images in pixels..

so you can then convert pixels into centimeter ,like you have 200 pixels of distance then your centimeter will be like ---> (200/ 47) = 4.25 centimeter

int distance = imageview1.frame.origin.y - imageview2.frame.origin.y;

int pixeltoCentrimeter = distance/47;

Happy Coding!!!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top