Chirag Shah
Chirag Shah

Reputation: 3016

Is there any way to make like iPhone progressbar in Apple Watch?

Hello all i am new in Apple Watch development and Is there any way to display progress bar in Apple Watch? I have one application in which there is progress bar which updated with user location. i implemented same thing in iPhone but now i want to implement same thing in Apple Watch. Is there any possible way to do this?

Upvotes: 5

Views: 2551

Answers (3)

Henrik
Henrik

Reputation: 1

I have found an easier way.

You can do it using two groups. The process similar as Fizker's answer.

  1. Add a group where you want the progress bar. The group should have the size of the bar at 100% and fixed height.
  2. Add an other group to the previous group using the same fixed height.
  3. Create an outlet for the second group. (eg: progressGroup)
  4. In your code call progressGroup.setRelativeWidth(CGFloat(currentValue / maxValue), withAdjustment: 0)

Upvotes: 0

Fizker
Fizker

Reputation: 2634

The most simple way for a solid-color progress bar in watchOS 2+ requires 1 image:

  1. Add a group where you want the progress bar. The group should have the size of the bar at 100%.
  2. Add a WKInterfaceImage to the group with an image of solid color.
  3. In your code, call progressBarImage.setRelativeWidth(CGFloat(currentValue / maxValue), withAdjustment: 0) whenever the current value changes.

If you want a vertical progress bar, there is afunction for that: progressBarImage.setRelativeHeight(CGFloat(currentValue / maxValue), withAdjustment: 0).

You could also create the image dynamically on the phone. I leave this as an exercise for the reader.

Upvotes: 10

cnoon
cnoon

Reputation: 16663

There is not a progress bar in WatchKit at the moment.

Workaround

A fairly easy workaround would be to design a WKInterfaceImage that looks like a progress bar along with the progressive images to fill in the bar. Then update the current image displayed to match the percentage that your user's location has progressed.

Upvotes: 4

Related Questions