Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/google-sheets/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
UIView在动画制作期间获取位置_Uiview_Calayer_Quartz Graphics_Uiviewanimation - Fatal编程技术网

UIView在动画制作期间获取位置

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

我在Stack和其他网站上都看过了这个问题的每一个例子,但对我来说仍然不可行。我试图在动画处于会话中时获取对象的位置

以下是我所拥有的:

- (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;
}