我确定这很简单,但我正在尝试将一组图像添加到图层中。这是我到目前为止所拥有的:
// Create the fish layer
fishLayer = [CALayer layer];
//fish = [UIImageView imageNamed:@"Fish.png"];
fish.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"swim01.png"],
[UIImage imageNamed:@"swim02.png"],
[UIImage imageNamed:@"swim03.png"],
[UIImage imageNamed:@"swim04.png"],
[UIImage imageNamed:@"swim05.png"],
[UIImage imageNamed:@"swim06.png"],
[UIImage imageNamed:@"swim05.png"],
[UIImage imageNamed:@"swim04.png"],
[UIImage imageNamed:@"swim03.png"],
[UIImage imageNamed:@"swim02.png"], nil];
fish.animationDuration = 1.50;
fish.animationRepeatCount = -1;
[fish startAnimating];
//[self.view addSubview:fish];
//This should add the animated array to layer.
fishLayer.contents = fish;
fishLayer.bounds = CGRectMake(0, 0, 56, 56);
fishLayer.position = CGPointMake(self.view.bounds.size.height / 2,
self.view.bounds.size.width / 2);
[self.view.layer addSublayer:fishLayer];
没有错误,但图像数组没有出现在屏幕上。我想也许这条线是probem..
fishLayer.contents = fish;
我已将 imageview 添加到我的头文件中并将其添加到 XIB
如果可以的话请帮忙,
干杯,
亚当