3
我想在CALayer的旋轉變換度高於90時添加背景圖像。旋轉90度後,如何將圖像添加到CALayer背面?
它就像Flipboard翻轉動畫一樣。
這是我當前的代碼:
CALayer *layer = self.view.layer;
int frames = 130;
layer.anchorPoint = CGPointMake(0, 0.5);
CATransform3D transform = CATransform3DIdentity;
transform.m34 = 1.0/-2000.0;
transform = CATransform3DRotate(transform, -frames * M_PI/180.0, 0.0, 1.0, 0.0);
self.view.layer.transform = transform;
CAKeyframeAnimation *pivot = [CAKeyframeAnimation animationWithKeyPath:@"transform"];
NSMutableArray *values = [[NSMutableArray alloc] initWithCapacity:45];
NSMutableArray *times = [[NSMutableArray alloc] initWithCapacity:45];
for (int i = 0; i < frames; i++) {
CATransform3D transform = CATransform3DIdentity;
transform.m34 = 1.0/-2000.0;
transform = CATransform3DRotate(transform, -M_PI/180.0 * i, 0.0, 1.0, 0.0);
[values addObject:[NSValue valueWithCATransform3D:transform]];
[times addObject:[NSNumber numberWithFloat:(float)i/(frames - 1)]];
}
pivot.values = values;
pivot.keyTimes = times;
[values release];
[times release];
pivot.duration = 0.5f;
pivot.calculationMode = kCAAnimationLinear;
[layer addAnimation: pivot forKey: @"pivot"];
誰能告訴我如何添加回圖像就像翻頁效果。
謝謝你的提示。我最終同時製作了兩層動畫,並且當程度高於90時,背層會自動到達前面。我沒有觸及doubleSided屬性。謝謝你們一樣。 – nonamelive 2010-12-21 14:59:52