Homework 6: Control Arc with a slider

For this lesson, we are going to draw on new resource: the Hacking with Swift website. Hacking with Swift was the  first good resource I found when the SwiftUI beta was released in the summer of 2019 and it has a lot of great lessons and useful code samples.

To start this exercise, visit the Hacking With Swift slider lesson and familiarize yourself with the code sample that illustrates the process of creating a slider and reading values from it.

Steps

  1. Your first task in this exercise is to create an arc and a slider that controls the size of the arc. Ie. As you slide to the right or left the arc will either grow or shrink, depending on how you set things up.
  2. The second task is to create a text field that captures the slider value.
  3. 3. As an extra challenge, figure out how to get the value to display without decimal points.
    • BIG Hint: wrap an Int( ) around the slider value that appears in your text field in order to convert the value, which is a double that displays decimal places, to an integer instead.

Demo

Part 2

Now that you’ve built an arc that’s controlled with a slider, create a new SwiftUI file and make a progress indicator that is also controlled with a slider!

Hint: you can reuse your code from the textbook and your arc to get started with the progress indicator.

Demo