这是我的问题。 我想制作一张图片的动画,我想让它绕过另一张图片,但我不知道该怎么做。我只想让它变成(不是旋转,而是旋转的动作,就像它绕着一个圆圈旋转一样)。我怎么能这样做?mak a uiimage查看其他图片
这里是我的代码:
-(void){
CALayer *orbit1 = [CALayer layer];
orbit1.bounds = CGRectMake(0, 0, 200, 200);
orbit1.position = centre.center;
orbit1.cornerRadius = 100;
orbit1.borderColor= [UIColor redColor].CGColor;
orbit1.borderWidth = 1.5;
planet1 = [CALayer layer];
planet1.bounds = CGRectMake(0, 0, 44.0, 20.0);
planet1.position = CGPointMake(160, 25);
planet1.contents = (id)([UIImage imageNamed:@"bouletest_05.png"].CGImage);
[orbit1 addSublayer:planet1];
CABasicAnimation *anim1 = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
anim1.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
anim1.fromValue = [NSNumber numberWithFloat:0];
anim1.toValue = [NSNumber numberWithFloat:((360*M_PI)/180)];
anim1.repeatCount = HUGE_VALF;
anim1.duration = 10.0;
[orbit1 addAnimation:anim1 forKey:@"transform"];
[self.view.layer addSublayer:orbit1];
}
然后:
-(void)creation{
imageView2 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"abouffer_03.png"]];
[[self view] addSubview:imageView2];
imageView2.center=planet1.center;
}
看看最后一行:imageView2.center = planet1.center;问题就在这里
检查[石英2D节目指南(http://developer.apple.com/library/mac/documentation/graphicsimaging/conceptual/drawingwithquartz2d/dq_affine/dq_affine.html#//apple_ref/doc/uid/TP30001066-CH204 -SW1)。它很好地解释了它。 – ender