动画从中心扩展到边缘,在下面显示parentView

时间:2017-08-23 06:50:21

标签: ios objective-c animation

我添加了一个UIView(其中包含一个UIVisualEffectView - blur)作为另一个视图的子视图。我想将子视图从其中心向外朝向边缘以放射状方式设置动画,就像一个扩展的圆圈。这应该在下面显示它的superView。

这是我的代码:

self.blurView =  [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, imageHeight)];
[superView addSubview: self.blurView];
UIVisualEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
UIVisualEffectView *visualEffectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
visualEffectView.frame = self.blurView.bounds;
[self.blurView addSubview:visualEffectButtonView];

3 个答案:

答案 0 :(得分:1)

[UIView animateWithDuration:3.0 delay:0 options:UIViewAnimationOptionCurveLinear  animations:^{
        //code with animation
        self.blurView.frame = CGRectMake(self.blurView.frame.origin.x, 
                    -self.blurView.frame.size.height, 
                    self.blurView.frame.size.width, 
                    self.blurView.frame.size.height);
    } completion:^(BOOL finished) {
        //code for completion
        [self.blurView removeFromSuperview];
    }];

答案 1 :(得分:0)

使用UIView动画

  [UIView animateWithDuration:0.5
        delay:1.0
        options: UIViewAnimationCurveEaseOut
        animations:^{
            visualEffectView.alpha = 0;
        }completion:^(BOOL finished){
            [visualEffectView removeFromSuperview];
        }];

答案 2 :(得分:0)

如果您想维护框架:

  [UIView animateWithDuration:0.5
        delay:0.0
        options: UIViewAnimationCurveEaseOut
        animations:^{
            viewToAnimate.transform = CGAffineTransformMakeTranslation(x,y);
            viewToAnimate.alpha = 0.0f;

        }completion:^(BOOL finished){

        }];

使用x,y坐标向任意方向移动(x向左和向右移动,y向上和向下移动,在每种情况下,分别是值是负还是正),例如, x = 10,将视图向右移动10个像素。