0
我試圖用一種又一種的動畫書風格動畫一系列圖像。當我在Apple TV模擬器上運行下面的代碼時,我看到一個空白的白色透明屏幕,它是默認的。主視圖和我的圖像視圖似乎消失了。任何建議爲什麼請?Apple TV上的CAKeyframeAnimation沒有顯示
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.view.backgroundColor = [UIColor blackColor];
self.imageview1 =[[UIImageView alloc] initWithFrame:CGRectMake(0,0,480,1080)];
self.imageview1.backgroundColor = [UIColor redColor];
[self.view addSubview:self.imageview1];
self.array1 = [NSMutableArray array];
for(int i = 0; i <10; i++)
{
NSString *imageName = [NSString stringWithFormat:@"loop_00_%d",i];
//NSLog(imageName);
NSString *path = [[NSBundle mainBundle] pathForResource:imageName ofType:@"jpg"];
UIImage *image = [UIImage imageWithContentsOfFile:path];
[self.array1 addObject:image];
}
[self animateImages];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void)animateImages
{
CAKeyframeAnimation *keyframeAnimation = [CAKeyframeAnimation animationWithKeyPath:@"contents"];
keyframeAnimation.values = self.array1; // array with images
keyframeAnimation.repeatCount = 1.0f;
keyframeAnimation.duration = 10.0;
keyframeAnimation.removedOnCompletion = YES;
CALayer *layer = self.imageview1.layer;
[layer addAnimation:keyframeAnimation
forKey:@"flingAnimation"];
}