我需要在单个视图中显示图像数组,这些图像在icarousel(时间机器,封面流等等)中具有各种效果。我将使用单一样式,其中必须显示所有图像。 这是我的代码.M文件..
UIImage *img=[[UIImageView alloc]initWithFrame:CGRectMake(30, 30, 290, 400)];
NSLog(@"hi");
img.image=[NSArray arrayWithObjects:[UIImage imageNamed:@"Cover_0.png"],
[UIImage imageNamed:@"Cover_1.png"],
[UIImage imageNamed:@"Cover_2.png"],
[UIImage imageNamed:@"Cover_3.png"],
[UIImage imageNamed:@"Cover_4.png"],
[UIImage imageNamed:@"Cover_5.png"],
[UIImage imageNamed:@"Cover_6.png"],
[UIImage imageNamed:@"Cover_7.png"],nil];
但它没有用......任何人都可以帮忙......
答案 0 :(得分:6)
更新:根据您最新的编辑,您的问题完全改变了,因此我的回答不适用。
改为使用animationImages
:
UIImageView *img=[[UIImageView alloc]initWithFrame:CGRectMake(30, 30, 290, 400)];
img.animationImages=[NSArray arrayWithObjects:[UIImage imageNamed:@"Cover_0.png"],
[UIImage imageNamed:@"Cover_1.png"],
[UIImage imageNamed:@"Cover_2.png"],
[UIImage imageNamed:@"Cover_3.png"],
[UIImage imageNamed:@"Cover_4.png"],
[UIImage imageNamed:@"Cover_5.png"],
[UIImage imageNamed:@"Cover_6.png"],
[UIImage imageNamed:@"Cover_7.png"],nil];
animationImages
用于动画的UIImage对象数组。
@property(nonatomic, copy) NSArray *animationImages
讨论数组必须包含UIImage对象。你可以使用 数组中的同一个图像对象不止一次。设置此属性 除了nil之外的值隐藏了由图像表示的图像 属性。默认情况下,此属性的值为nil。
状况 适用于iOS 2.0及更高版本。 也可以看看 @property图片 @property contentMode(UIView) 宣告进入 UIImageView.h
答案 1 :(得分:2)
你试过吗
NSArray *frames = [NSArray arrayWithObjects:
[UIImage imageWithName:@"a.png"],
[UIImage imageWithName:@"b.png"],
[UIImage imageWithName:@"c.png"],
[UIImage imageWithName:@"d.png"],
[UIImage imageWithName:@"e.png"],
nil];
UIImageView *animatedIMvw = [[UIImageView alloc] init];
animatedIMvw.animationImages = frames;
[animatedIMvw startAnimating];
答案 2 :(得分:1)
看看这个简单的例子:http://appsamuck.com/day2.html
修改
主页似乎已经破了,所以请检查一下:
http://web.archive.org/web/20090207210729/http://appsamuck.com/day2.html