objective c - How to slowly fill the NSProgressIndicator (Progress Bar) from 0 to 100? -
task: take progress bar (nsprogressindicator) 0 100 smoothly.
problem: progress bar getting 0 100 not smoothly.
what have done yet:
// scan click on prgress should start -(void)scannowclick:(id)sender { // setting initial value of progress bar [progressbar setdoublevalue:0]; // starting timer [nstimer scheduledtimerwithtimeinterval:0.5 target:self selector:@selector(callafter10sec:) userinfo:nil repeats:yes]; } // timer update progress bar -(void)callafter10sec:(nstimer *)time { double value = [progressbar doublevalue]+10; [[progressbar animator] setdoublevalue:value]; if(value >= 100) { [time invalidate]; } }
/// layer set
you should use cadisplaylink
, not nstimer
when dealing ui related updates.
the link called 60 times per second (per refresh rate of screen)
in callback should calculate proportion advance view
Comments
Post a Comment