iOS中的多彩进度条

时间:2013-04-24 09:51:41

标签: ios uiprogressbar

progress getting started

progress completed

我需要在iOS应用程序中设置这种Progressbar。任何人都可以建议我在完成进度后如何获得这种外观(第2张图片)。

4 个答案:

答案 0 :(得分:1)

查看cocoa controls

中的一些内容

YLProgressBar for iOS

答案 1 :(得分:1)

看到这个:

AMGProgressView for iOS

答案 2 :(得分: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];
        }

pragma mark -

pragma mark进度条方法

        -(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

答案 3 :(得分:0)

sample

看到这个:

MJProgressView for iOS