How to quickly get the exact point of objects?

I am using UIProgressView and want to bind the image routine to the% progress, as shown in the figure below:

enter image description here

I want to get the coordinate of the progress indicator and the red subset, as shown in the figure, to “ stick ” with a touch of progress, no matter what progress will be.

0
source share
1 answer

You can start by centering the image vertically using a progress view using constraints or programmatically, as shown below.

 imageView.center.y = progressView.center.y 

Then, when you update the progress, you can calculate the center x coordinate for the image using the adjusted progress and the width of the progress view.

 imageView.center.x = progressView.progress * progressView.frame.width 

Although you may need to add a registration if the super view of the progress view does not have the same width.

OR

You can use UISlider ; it comes with a progress tracking track and thumb slider that you can customize. Thus, you can even have user interaction if necessary - otherwise user interaction can be turned off, and you can set the progress programmatically.

0
source

Source: https://habr.com/ru/post/1260686/


All Articles