Sometimes our app needs to be connected to the Internet or other time-consuming operations, need to prompt the user, the good way to prompt is the progress bar or a circular gear, prompting the user to have the operation in progress. We add two buttons to the previous scene, download and stop, click to download the gear to start the turn, click Stop to stop.
and drag this component into our scene.
Set Format:
Effect
Connect the buttons and gears to the controller:
@IBOutlet weak var loading:uiactivityindicatorview! @IBAction func Stopbutton (Sender:uibutton) { } @IBAction func Downloadbutton (Sender:uibutton) { }
The operation of this space is simple, add the following code to the action of the two buttons:
@IBAction func Stopbutton (Sender:uibutton) { loading.stopanimating () } @IBAction func Downloadbutton ( Sender:uibutton) { loading.startanimating () }
Everyone can try the effect.
Swift UI Special training Activityindicator