Objective-C的UIViewImage动画 [英] Objective-C UIViewImage animation

查看:145
本文介绍了Objective-C的UIViewImage动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在我能够做到用低于code一个简单的动画。
但是,下面的解决方案,需要我predefine图像名称。
我怎么可以这样做NSArray.push(image1.png);例如?然后,动态数组作为animationImages分配?

感谢您,
T恤

 的UIImageView * animationView = [[UIImageView的页头] initWithFrame:方法self.view.frame];animationView.animationImages = [NSArray的arrayWithObjects:
[UIImage的imageNamed:@过渡1.png],
[UIImage的imageNamed:@过渡2.png],
[UIImage的imageNamed:@过渡3.png],
[UIImage的imageNamed:@过渡4.png],
[UIImage的imageNamed:@过渡5.png],无]


解决方案

您可以使用<一个href=\"http://developer.apple.com/mac/library/DOCUMENTATION/Cocoa/Reference/Foundation/Classes/NSMutableArray%5FClass/Reference/Reference.html\"相对=nofollow> 的NSMutableArray ,并使用 ADDOBJECT对象添加到它:。例如:

 的NSMutableArray * A = [NSMutableArray的阵列]
[A ADDOBJECT:[UIImage的imageNamed:@过渡1.png]];
[A ADDOBJECT:[UIImage的imageNamed:@过渡1.png]];animationView.animationImages =一个;

Right now I'm able to do a simple animation using the code below. However, the below solution needs me to predefine the image names. How can I do something like NSArray.push("image1.png"); for example? Then assign the dynamic array as the animationImages?

Thank you, Tee

UIImageView* animationView = [[UIImageView alloc] initWithFrame:self.view.frame];

animationView.animationImages = [NSArray arrayWithObjects:  
[UIImage imageNamed:@"transition 1.png"],
[UIImage imageNamed:@"transition 2.png"],
[UIImage imageNamed:@"transition 3.png"],
[UIImage imageNamed:@"transition 4.png"],
[UIImage imageNamed:@"transition 5.png"], nil];

解决方案

You can use NSMutableArray, and add objects to it using addObject:. For example:

NSMutableArray *a = [NSMutableArray array];
[a addObject:[UIImage imageNamed:@"transition 1.png"]];
[a addObject:[UIImage imageNamed:@"transition 1.png"]];

animationView.animationImages = a;

这篇关于Objective-C的UIViewImage动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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