How to show % status or progress at UIView according to some % value?

Viewed 1266

How I can show the progress or % status like following image.

Here I am trying to show the % value of symptoms according to its percentage value like shown in the image.

I tried using UIView but, I don't know how to show percentage (%) data/progress like shown in the image.

Is there any solution or way to achieve this?

I still didn't Added Code.

here is the image

2 Answers

If you want to do it natively, you can use a UIProgressView. Create an @Outlet of that view and in your code, when you want to change the progress or set it, use the function

thenameofyouroutlet.setProgress (float, animated: bool)

The first parameter must be a number between 0.0 and 1.0, where 0.0 equals 0% and 1.0 equals 100%.

The second parameter must be true or false, true if you want to animate the progress, false if you want it to be set without animation.

Then, if you want a label that shows the progress, you can create a UILabel next to the bar, create your @Outlet, and in the same code where you set the progress, change the text of your label with thenameofyourlabel.text

Also, in storyboard you can set the color of the progress, and the color of the bar. example

You Can take 2 view, one over the other.

First View

Second View on top of it with Width Constant

Second View

Now when you need to show progress, update the width constraint as,

self.greenViewWidthConstraint.constant = self.greyView.frame.width * 0.80 (For 80%)
Related