1
我試圖添加一個動畫到UIImageView,但它總是失敗。爲什麼?下面是代碼:爲什麼我不能將動畫添加到UIImageView?
//(…)
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
animationImage = [[UIImageView alloc]initWithImage:newImage];
[self.view addSubview:animationImage];
CATransition *animation = [CATransition animation];
[animation setDelegate:self];
[animation setDuration:0.35];
[animation setTimingFunction:UIViewAnimationCurveEaseInOut];
animation.type = @"pageCurl";
animation.fillMode = kCAFillModeForwards;
animation.endProgress = 0.58;
[animation setRemovedOnCompletion:NO];
[[animationImage layer] addAnimation:animation forKey:@"pageCurlAnimation"];
好好嘗試一下工作:
的insteaad。奇怪的是,我的代碼與self.view圖層一起工作,但與animationImage圖層無關...... – Flocked 2010-03-31 05:09:26
因爲UIImageView繼承自UIView,所以您應該可以將動畫添加到其圖層。 – glorifiedHacker 2010-03-31 05:32:38
@Flocked:親愛的試試'animationImage.layer'並接受這個答案,因爲它也幫助我.. :) – rptwsthi 2012-06-14 07:08:17