3

基本上我有三个点应该在加载屏幕上连续变大和变小,我想知道做这样一个简单动画的最好方法是什么——编码还是其他?

4

1 回答 1

7

对于简单的动画,您可以使用 UIImageView 动画来为一组图像设置动画(即使用图像作为动画中的帧)。

UIImageView* dotsImageView= [[UIImageView alloc] initWithFrame:dotsFrame];

// load all the frames of your animation
dotsImageView.animationImages = @[[UIImage imageNamed:@"image1.png"],
                                  [UIImage imageNamed:@"image2.png"],
                                  [UIImage imageNamed:@"image3.png"]];

// set how long it will take to go through all images 
dotsImageView.animationDuration = 1.0;
// repeat the animation forever
dotsImageView.animationRepeatCount = 0;
// start the animation
[dotsImageView startAnimating];
// add it to the view
[self.view addSubview:dotsImageView];

如果您不想为点使用预设图像,您可以使用完成块将 UIView 动画链接在一起。这是关于 UIView 动画的教程: http ://www.raywenderlich.com/5478/uiview-animation-tutorial-practical-recipes

于 2013-08-19T21:17:30.900 回答