我是初学者,我试着继续熟悉CALayer .
再次感谢“阿历克山德·阿克斯”、“达姆里克”和“汤米”,因为现在我可以扭曲我的CALayer了!
看上去:

我想把我的手指移到灰色UIView上(用UIView和我的“卡片”移动如下:(举个例子,如果我的手指向左移动)
H 116而不是蓝色的卡片出现了.H 217f 218
也许我在做梦,这对我来说太难了,但如果你能给我建议,我会接受的!
谢谢!
发布于 2012-01-04 09:05:57
您可以像这样使用自定义的函数
- (void)moveAndRotateLayer: (CALayer *)layer withDuration:(double)duration degreeX:(double)degreeX y:(int)degreeY angle:(float)angle autoreverseEnable:(BOOL)ar repeatTime:(int)repeat andTimingFunctionType:(NSString *)type
{
// You should type the timing function type as "Liner", "EaseIn", "EaseOut" or "EaseInOut".
// The default option is the liner timing function.
// About these functions, look in the Apple's reference documents.
CAAnimationGroup *theGroup = [CAAnimationGroup animation];
CGPoint movement = CGPointMake(layer.position.x + degreeX, layer.position.y + degreeY);
NSArray *animations = [NSArray arrayWithObjects:[self moveLayers:layer to:movement duration:duration], [self rotateLayers:layer to:angle duration:duration], nil];
theGroup.duration = duration;
theGroup.repeatCount = repeat;
theGroup.autoreverses = ar;
if ([type isEqualToString:@"EaseIn"])
{
theGroup.timingFunction = [CAMediaTimingFunction functionWithName: kCAMediaTimingFunctionEaseIn];
}
else if ([type isEqualToString:@"EaseOut"])
{
theGroup.timingFunction = [CAMediaTimingFunction functionWithName: kCAMediaTimingFunctionEaseOut];
}
else if ([type isEqualToString:@"EaseInOut"])
{
theGroup.timingFunction = [CAMediaTimingFunction functionWithName: kCAMediaTimingFunctionEaseInEaseOut];
}
else
{
theGroup.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
}
theGroup.animations = [NSArray arrayWithArray:animations];
[layer addAnimation:theGroup forKey:@"movingAndRotating"];
}这是动画的解决方案,只是为了移动和旋转图层,
但是,我知道你可以定制自己。
这对你很有好处。你能做到。
祝好运!
https://stackoverflow.com/questions/6205320
复制相似问题