iOS版:自定义活动的指标 [英] iOS: Custom activity indicator

查看:153
本文介绍了iOS版:自定义活动的指标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建自定义活动的指标有两个图像的一个图像是静态的(在背景中)和另一个图像将在前面,它具有移动左,右,上,下​​(只是给动画感觉)。我试着用下面的code(其错误的)。谁能帮我,怎么做动画

 的UIImage * statusImage = [UIImage的imageNamed:@image1.png];
*的UIImageView = activityImageView [[UIImageView的页头]
                                  initWithImage:statusImage];
//添加将用于为动画更多图像
activityImageView.animationImages = [NSArray的arrayWithObjects:
                                     [UIImage的imageNamed:@image1.png],
                                     [UIImage的imageNamed:@image2.png],无]
//设置动画的持续时间(用它玩
//直到它看起来不错你)
activityImageView.animationDuration = 7;activityImageView.frame = CGRectMake(
                                     self.view.frame.size.width / 2
                                     -statusImage.size.width / 3,
                                     self.view.frame.size.height / 2
                                     -statusImage.size.height / 3,
                                     statusImage.size.width / 3,
                                     statusImage.size.height / 3);//开始动画
[activityImageView startAnimating]


解决方案

创建要在各个角落移动,并将其添加为定位对象层的CAAnimation。希望它能帮助

I am trying to create custom activity indicator it has two images one image will be static (in the background) and another image will be in the front, it has to move left, right, top and bottom (just to give animation feel). I tried to use the following code (Its wrong one). Can anyone help me, how to do animation

UIImage *statusImage = [UIImage imageNamed:@"image1.png"];
UIImageView *activityImageView = [[UIImageView alloc]
                                  initWithImage:statusImage];


//Add more images which will be used for the animation
activityImageView.animationImages = [NSArray arrayWithObjects:
                                     [UIImage imageNamed:@"image1.png"],
                                     [UIImage imageNamed:@"image2.png"], nil];


//Set the duration of the animation (play with it
//until it looks nice for you)
activityImageView.animationDuration = 7;

activityImageView.frame = CGRectMake(
                                     self.view.frame.size.width/2
                                     -statusImage.size.width/3,
                                     self.view.frame.size.height/2
                                     -statusImage.size.height/3,
                                     statusImage.size.width/3,
                                     statusImage.size.height/3);

//Start the animation
[activityImageView startAnimating];

解决方案

Create a CAAnimation for the layer which you want to move at each corners and add it as a positioning object. Hope it helps

这篇关于iOS版:自定义活动的指标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆