开发者

Making a visual bar timer for iPhone

I've looked up all results for progress bars and changing the width of an image but it only refers to scaling, and the progress bars aren't customizable so that they fit other functions or design schemes... unless I missed that part. I'm trying to make a bar timer that crops off of the right over a period of time. I tried using an NStimer so that it would subtract from a value each time its function is called. the Timerbar function gets called as a result of another timer invalidating and it works. What doesn't work is that the width isn't changing just the position. further more I kee开发者_运维知识库p getting values like Inf and 0 for power and pwrBarWidth I was sure that the changes would occur when Mult was plugged into the equation. it seems like casting mult as an int is causing problems but i'm not sure exactly how.

int pwrBarMaxWidth = 137;
int pwrBarWidth 0;
int limit = 1;
float mult;
float power = 0;



-(void) Timerbar:(NSTimer *)barTimer {


 if(!waitForPlayer) {

  [barTimer invalidate];

 }
 if(mult > 0.0) {
  mult -= 0.001 * [colorChoices count];
  if(mult < 0.0) { 
   mult = 0.0;

  }

 } 
 power =  (mult * 10) / pwrBarMaxWidth; 
 pwrBarWidth = (int)power  % limit; // causes the bar to repeat after it reaches a certain point
 //At this point however the variable Power is always "inf" and PwrBarWidth is always 0.


 [powerBar setBounds:CGRectMake(powerBar.frame.origin.x, 
          powerBar.frame.origin.y,pwrBarWidth,20)]; //supposed to change the crop of the bar
}

Any reason why I'm getting inf as a value for power, 0 as a value for pwrBarWidth, and the bar itself isn't cropping? if this question is a bit vague i'll provide more information as needed.


incorrect formatting, used state icons for bar width

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜