用于显示应用程序加载进度的UIImageView

时间:2022-10-10 20:01:26

I have a launch screen which contains application logo, say test. As the application will start loading, the logo will gradually starts filling like this. In the end, when the application will be loaded completely, it will look like this.

我有一个包含应用程序标志的启动屏幕,比如test。当应用程序开始加载时,标志将逐渐开始像这样填充。最后,当应用程序将被完全加载时,它将像这样。

One point I would like to mention here is that the colour is being filled from left to right. And there will not be a single colour. It contains different colours for different characters.

我想在这里提到的一点是颜色是从左到右填充的。不会有单一的颜色。它包含不同颜色的不同字符。

After googling, I come to know that I need to use two images completely filled image with red colour and another one without colour, one on the top of other and apply animations on it. So far I did that, but not succeeded in animating it from left to right.

在谷歌上搜索之后,我发现我需要使用两个完全填充了红色的图片和一个没有颜色的图片,一个在另一个上面,并在上面应用动画。到目前为止,我做了,但没有成功地从左到右动画它。

Same functionality I need to apply in android also. Can someone please suggest ?

同样的功能我也需要在android中应用。谁能推荐一下吗?

2 个解决方案

#1


2  

Have two images blank & filled overlapped with each other. Modify the width of filled image on the fly depending on the progress.

有两个图像空白和填补彼此重叠。根据进度修改动态填充图像的宽度。

static int max_image_width = 250

//assumption
UIImage *blankImage;
UIImage *filledImage;

-(void)viewDidAppear:(BOOL)animated{
    [super viewDidAppear:animated];
    [self fillImage:1]; /*any value between 0 and 1 */
}

-(void)fillImage:(CGFloat)progress{

    CGFloat image_width = max_image_width * progress;

    [UIView animateWithDuration:2  animations:^{

        CGRect frame = self.filledImage.frame;
        frame.size.width = image_width;
        self.filledImage.frame = frame;
    }];

}


#2


1  

Here's what you can do is that use sprite sheet animation in your iOS app, you can get the example from here http://www.icodeblog.com/2009/07/24/iphone-programming-tutorial-animating-a-game-sprite/ OR you can use a GIF Image code support available here https://github.com/arturogutierrez/Animated-GIF-iPhone and here https://*.com/a/4386709/1042240 (SO's own answer)

你可以在你的iOS应用程序中使用sprite表单动画,你可以从这里得到这个例子:http://www.icodeblog.com/2009/07/24/iphone-编程-tutorial- animatinga -game-sprite/或者你可以在这里使用GIF图像代码支持,https://github.com/arturogutierrez/animatedgif - iphone,这里是https://*.com/a/4386709/1042240(所以是自己的答案)

Would be happy to hear what you try and implement.

很高兴听到你的尝试和实施。

#1


2  

Have two images blank & filled overlapped with each other. Modify the width of filled image on the fly depending on the progress.

有两个图像空白和填补彼此重叠。根据进度修改动态填充图像的宽度。

static int max_image_width = 250

//assumption
UIImage *blankImage;
UIImage *filledImage;

-(void)viewDidAppear:(BOOL)animated{
    [super viewDidAppear:animated];
    [self fillImage:1]; /*any value between 0 and 1 */
}

-(void)fillImage:(CGFloat)progress{

    CGFloat image_width = max_image_width * progress;

    [UIView animateWithDuration:2  animations:^{

        CGRect frame = self.filledImage.frame;
        frame.size.width = image_width;
        self.filledImage.frame = frame;
    }];

}


#2


1  

Here's what you can do is that use sprite sheet animation in your iOS app, you can get the example from here http://www.icodeblog.com/2009/07/24/iphone-programming-tutorial-animating-a-game-sprite/ OR you can use a GIF Image code support available here https://github.com/arturogutierrez/Animated-GIF-iPhone and here https://*.com/a/4386709/1042240 (SO's own answer)

你可以在你的iOS应用程序中使用sprite表单动画,你可以从这里得到这个例子:http://www.icodeblog.com/2009/07/24/iphone-编程-tutorial- animatinga -game-sprite/或者你可以在这里使用GIF图像代码支持,https://github.com/arturogutierrez/animatedgif - iphone,这里是https://*.com/a/4386709/1042240(所以是自己的答案)

Would be happy to hear what you try and implement.

很高兴听到你的尝试和实施。