2013-04-24 44 views
2

progress getting started五彩进度iOS中

progress completed

我需要设置这种进度的iOS中的应用。任何人都可以建议我的进展完成后怎样才能获得这种样子(第二张图)。你可以改变图像按规定:

+0

它是可重复的= [seethis](http://stackoverflow.com/questions/16030464/how-to-fill-circularprogressbar-with-multiple-colours/16030524#16030524) – 2013-04-24 10:00:31

+1

I sug指示您使用自定义视图作为进度条,或者也可以使用自定义图像视图。 – HarshIT 2013-04-24 10:10:39

回答

0

试试我的自定义代码检查出一些东西。

.h文件中

 //ProgressBar 
      NSTimer *splashtimer; 
      UIImage *ProgressBarBackgroundImage; 
      UIImageView *ProgressBarLeft; 
      UIImageView *ProgressBarRight; 
      UIImageView *ProgressBarMiddle; 
      UIImageView *LoadingBackground; 

      NSInteger totalSizeOfProgressBarAnimation; 
      NSInteger totalCountOfProgressBarAnimation; 
      NSInteger NoOfPercentage; 
      NSInteger startingvalue; 
      int progressValue; 


     //ProgressBar 
     @property (nonatomic,retain) UIImageView *ProgressBarLeft; 
     @property (nonatomic,retain) UIImageView *ProgressBarRight; 
     @property (nonatomic,retain) UIImageView *ProgressBarMiddle; 
     @property (nonatomic,retain) UIImageView *LoadingBackground; 

     - (void) ProgressBarSizeCheck:(NSInteger)starting:(NSInteger)ending; 

.m文件

 @synthesize ProgressBarLeft,ProgressBarRight,ProgressBarMiddle,LoadingBackground; 
     - (void)viewDidLoad { 
      [super viewDidLoad] 

      splashtimer = [NSTimer scheduledTimerWithTimeInterval: 0.75 target: self selector: @selector(startMoveProgress) userInfo: nil repeats: NO]; 

      ProgressBarLeft = [[UIImageView alloc] init]; 
      ProgressBarMiddle = [[UIImageView alloc] init]; 
      ProgressBarRight = [[UIImageView alloc] init]; 
      LoadingBackground = [[UIImageView alloc] init]; 
      ProgressBarBackgroundImage = [UIImage imageNamed: @"loaderbg.png"]; 
      [self.view addSubview: LoadingBackground]; 
     } 

编译马克 -

编译标记进度条法

 -(void)ProgressBarSizeCheck:(NSInteger)starting:(NSInteger)ending { 
      startingvalue = starting; 
      endingValue = ending; 
      NoOfPercentage = ending - starting; 

      if (startingvalue==0) { 
       //ProgressBarLeft Image 
       ProgressBarLeft.frame = CGRectMake(23,410,10,20); 
       UIImage *ProgressBarImage = [UIImage imageNamed: @"loaderleftpart.png"]; 
       ProgressBarLeft.image = ProgressBarImage; 
       [self.view addSubview: ProgressBarLeft]; 
       //LeftImageOver 

       //ProgressBarMiddleImage 
       ProgressBarMiddle.frame = CGRectMake(33,410,0,20); 
       UIImage *ProgressBarImageMiddle = [UIImage imageNamed: @"loadercenterpart.png"]; 
       ProgressBarMiddle.image = ProgressBarImageMiddle; 
       [self.view addSubview: ProgressBarMiddle]; 
       //MiddleImageOver 

       //ProgressBarRightImage 
       ProgressBarRight.frame = CGRectMake(33,410,10,20); 
       UIImage *ProgressBarImageRight = [UIImage imageNamed: @"loaderrightpart.png"]; 
       ProgressBarRight.image = ProgressBarImageRight; 
       [self.view addSubview: ProgressBarRight]; 
       //RightImageOver 

       totalSizeOfProgressBarAnimation = 276 * NoOfPercentage/100; 
       totalSizeOfProgressBarAnimation=totalSizeOfProgressBarAnimation-20; 
       int Duration=NoOfPercentage/10; 
       [self moveDown:Duration:totalSizeOfProgressBarAnimation]; 

      } 
      else { 
       totalSizeOfProgressBarAnimation = 276 * startingvalue/100; 
       totalSizeOfProgressBarAnimation=totalSizeOfProgressBarAnimation-20; 

       //ProgressBarLeftImage 
       ProgressBarLeft.frame = CGRectMake(23,410,10,20); 
       UIImage *ProgressBarImage = [UIImage imageNamed: @"loaderleftpart.png"]; 
       ProgressBarLeft.image = ProgressBarImage; 
       [self.view addSubview: ProgressBarLeft]; 
       //LeftImageOver 

       //ProgressbarMiddleImage 
       ProgressBarMiddle.frame = CGRectMake(33,410,totalSizeOfProgressBarAnimation,20); 
       UIImage *ProgressBarImageMiddle = [UIImage imageNamed: @"loadercenterpart.png"]; 
       ProgressBarMiddle.image = ProgressBarImageMiddle; 
       [self.view addSubview: ProgressBarMiddle]; 
       //MiddleImageOver 

       //ProgressBarRightImage 
       ProgressBarRight.frame = CGRectMake(33+totalSizeOfProgressBarAnimation,410,10,20); 
       UIImage *ProgressBarImageRight = [UIImage imageNamed: @"loaderrightpart.png"]; 
       ProgressBarRight.image = ProgressBarImageRight; 
       [self.view addSubview: ProgressBarRight]; 
       //RightImageOver 

       totalSizeOfProgressBarAnimation = 276 * NoOfPercentage/100; 
       int Duration=NoOfPercentage/10; 
       [self moveDown:Duration:totalSizeOfProgressBarAnimation]; 
      } 

     } 

     -(void)moveDown:(NSInteger)animationDuration:(NSInteger)size { 
      CGRect startFrame = [ProgressBarMiddle frame]; 
      [UIView beginAnimations:@"move10" context:NULL]; 
      [UIView setAnimationDuration:animationDuration]; 
      [ProgressBarMiddle setFrame:CGRectMake(startFrame.origin.x, 410, startFrame.size.width+size, startFrame.size.height)]; 
      [ProgressBarRight setFrame:CGRectMake(33+(startFrame.size.width+size),410,10,20)]; 
      [UIView setAnimationDelegate:self]; 
      [UIView setAnimationCurve: UIViewAnimationCurveEaseOut]; 
      [UIView commitAnimations]; 

      splashtimer = [NSTimer scheduledTimerWithTimeInterval: animationDuration target: self selector: @selector(pushTabControl) userInfo: nil repeats: NO]; 
     } 
     -(void)pushTabControl { 
      [self.navigationController pushViewController: tabObj animated:YES]; 
     } 

     -(void) startMoveProgress { 

      LoadingBackground.frame = CGRectMake(22,410,276,22); 
      UIImage *ProgressBarBackgroundImage = [UIImage imageNamed: @"loaderbg.png"]; 
      [LoadingBackground setUserInteractionEnabled: YES]; 
      LoadingBackground.image = ProgressBarBackgroundImage; 
      [self ProgressBarSizeCheck:0:100]; 

     } 

//看到的影像

1)loaderbg.png

loaderbg

2)loadercenterpart

centerpart

3)loaderrightpart rightpart

4)loderleftpart

enter image description here