UIView在动画制作期间获取位置
我在Stack和其他网站上都看过了这个问题的每一个例子,但对我来说仍然不可行。我试图在动画处于会话中时获取对象的位置 以下是我所拥有的:UIView在动画制作期间获取位置,uiview,calayer,quartz-graphics,uiviewanimation,Uiview,Calayer,Quartz Graphics,Uiviewanimation,我在Stack和其他网站上都看过了这个问题的每一个例子,但对我来说仍然不可行。我试图在动画处于会话中时获取对象的位置 以下是我所拥有的: - (void)viewDidLoad{ currentPosition = [[bikeMotion.layer presentationLayer] center]; //its a CGPoint } - (void)doAnimation { bikeMotion = [[DotAnimation alloc]initWithFram
- (void)viewDidLoad{
currentPosition = [[bikeMotion.layer presentationLayer] center]; //its a CGPoint
}
- (void)doAnimation {
bikeMotion = [[DotAnimation alloc]initWithFrame:CGRectMake((*bikePathPoints)[0].x, (*bikePathPoints)[0].y, 8, 8)];
//... [self animate stuff]...
[NSTimer scheduledTimerWithTimeInterval:0.07f target:self selector:@selector(backgroundAnimations) userInfo:nil repeats:YES];
}
-(void)backgroundAnimations{
cout << currentPosition.x << endl;
}
-(void)viewDidLoad{
currentPosition=[[bikmotion.layer presentationLayer]center];//它是一个CGPoint
}
-(无效)送达{
bikMotion=[[DotAnimation alloc]initWithFrame:CGRectMake((*bikePathPoints)[0].x,(*bikePathPoints)[0].y,8,8)];
//…[自我动画化的东西]。。。
[NSTimer scheduledTimerWithTimeInterval:0.07f目标:自选择器:@selector(backgroundAnimations)用户信息:无重复:是];
}
-(无效)背景动画{
您是否尝试过对象、层、锚点?您需要导入QuartzCore。实际上,插值起到了帮助作用。
- (void)viewDidLoad{
currentPosition = [[bikeMotion.layer presentationLayer] frame]; //its a CGRect
}
- (void)doAnimation {
bikeMotion = [[DotAnimation alloc]initWithFrame:CGRectMake((*bikePathPoints)[0].x, (*bikePathPoints)[0].y, 8, 8)];
//...[self animation stuff];
[NSTimer scheduledTimerWithTimeInterval:0.07f target:self selector:@selector(backgroundAnimations) userInfo:nil repeats:YES];
}
-(void)backgroundAnimations{
cout << currentPosition.origin.x << endl;
}
- (void)viewDidLoad{
p = (CALayer*)[bikeMotion.layer presentationLayer];
}
-(void)doAnimation{
bikeMotion = [[DotAnimation alloc]initWithFrame:CGRectMake((*bikePathPoints)[0].x, (*bikePathPoints)[0].y, 8, 8)];
[NSTimer scheduledTimerWithTimeInterval:0.07f target:self selector:@selector(backgroundAnimations) userInfo:nil repeats:YES];
}
-(void)backgroundAnimations{
CGPoint position = [p position];
cout << position.x << endl;
}