Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/106.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
Ios 视图动画';s隐藏在另一个视图后面的子视图_Ios_Objective C_Animation_Uiview - Fatal编程技术网

Ios 视图动画';s隐藏在另一个视图后面的子视图

Ios 视图动画';s隐藏在另一个视图后面的子视图,ios,objective-c,animation,uiview,Ios,Objective C,Animation,Uiview,我正在尝试设置UIImage的动画,这是interface builder中UIView的子视图。 我的问题是,这个动画“穿过”另一个视图,即表视图,然后它只是“走到”它的后面,并不会一直显示。 我的视图层次结构如下所示: View View SubviewToAnimate TableView 我已经尝试了[self.view-bringViewToFront:subview-to-animate] 在视图本身和动画中 动画代码: -(void)startAnimat

我正在尝试设置
UIImage
的动画,这是interface builder中
UIView
的子视图。 我的问题是,这个动画“穿过”另一个视图,即表视图,然后它只是“走到”它的后面,并不会一直显示。 我的视图层次结构如下所示:

View
   View
      SubviewToAnimate
   TableView
我已经尝试了
[self.view-bringViewToFront:subview-to-animate]
在视图本身和动画中

动画代码:

-(void)startAnimationWithImageView:(UIImageView*)imageView{

    imageViewToMove = imageView;
    imageViewFirstAlpha = imageViewToMove.alpha;

    firstCenterOfView = imageViewToMove.center;

    double firstX =self.parabelWidth*self.startValue;
    double firstY = self.parabelHeight*pow(self.startValue, 2);
    firstPointOfParabel = CGPointMake(firstX, firstY);

    if (points) {
        points = nil;
    }
    points =[[NSMutableArray alloc]init];

    for (int counter = self.startValue; counter < self.stopValue; counter++) {

        double y = self.parabelHeight*pow(counter, 2);
        double x = self.parabelWidth*counter;

        CGPoint point = CGPointMake(x, y);
        [points addObject:[NSValue valueWithCGPoint:point]];
        //DLog(@"point: %@", NSStringFromCGPoint(point));

    }

    animationCounter = 0;
    [self moveView];


}

-(void)moveView{

    if (animationCounter < points.count) {
        [UIView animateWithDuration:self.duration
                              delay:0
                            options:UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationCurveLinear
                         animations:^{

                             NSValue *val = [points objectAtIndex:animationCounter];
                             CGPoint point = [val CGPointValue];

                             double delta = 1.0/points.count;
                             imageViewToMove.center = CGPointMake(firstCenterOfView.x-firstPointOfParabel.x+point.x, firstCenterOfView.y-firstPointOfParabel.y+point.y);
                             imageViewToMove.alpha = sqrt(imageViewToMove.alpha-delta);

                             double scale = animationCounter*delta;
                             imageViewToMove.transform = CGAffineTransformMakeScale(sqrt(1-scale), sqrt(1-scale));

                             animationCounter++;

                         }
                         completion:^(BOOL finished){

                             [self moveView];

                         }];
    }else if (animationCounter == points.count) {
        imageViewToMove.center = firstCenterOfView;
        imageViewToMove.transform = CGAffineTransformMakeScale(1.0, 1.0);

        [UIView animateWithDuration:0.3
                              delay:0
                            options:UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationCurveEaseIn
                         animations:^{

                             imageViewToMove.alpha = imageViewFirstAlpha;

                         }
                         completion:NULL];
    }else
        return;


}
-(void)使用图像视图启动图像:(UIImageView*)图像视图{
imageViewToMove=imageView;
imageViewFirstAlpha=imageViewToMove.alpha;
firstCenterOfView=imageViewToMove.center;
double firstX=自抛物线宽度*自起始值;
双第一=自抛物线高度*功率(自起始值,2);
firstPointOfParabel=CGPointMake(firstX,firstY);
如果(点数){
分数=零;
}
points=[[NSMutableArray alloc]init];
for(int counter=self.startValue;counter
您不能使用
[self.view bringViewToFront:subview to animate]
将图像视图放在表视图的顶部,因为它不是表视图的同级视图

如果你有

View
    SubView
    ImageView (animated view)
    TableView
那代码就行了


或者,在您当前的层次结构中,您可以将子视图放在前面,这样可以将图像视图放在前面。

将子视图放在前面,效果非常好!非常感谢。(5分钟后接受回答)不用担心,乐意帮忙