Reputation: 1015
I'm using Xcode 4.6.1 to code in Objective-C, and I want to know how to set a progress bar values, I mean, to set the green part and the white part with some values. The data of the bar I want to implement are college subjects, so the green part is based by the subjects that the user already saw, and the white part by those that the user has not seen yet. So if there are 10 subjects in total and the user has just seen 5, the progress bar will be 50% green and 50% white.
Upvotes: 0
Views: 239
Reputation: 5361
See UIProgressView documentation: https://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIProgressView_Class/Reference/Reference.html
Assuming you've got a UIProgressView
named myProgressView
.
float currentProgress
contains the number of subjects the user has completed.
float totalSubjects
contains the number of total subjects available to the user.
// calculate progress (value must be 0.0 to 1.0)
float myProgress = currentProgress / totalSubjects;
[myProgressView setProgress:myProgress animated:YES];
Upvotes: 1