【问题标题】:Animation to expand from center to the edges, revealing parentView below动画从中心扩展到边缘,显示下面的 parentView
【发布时间】:2017-08-23 06:50:20
【问题描述】:

我添加了一个 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];

【问题讨论】:

    标签: ios objective-c animation


    【解决方案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];
        }];
    

    【讨论】:

    • 随着blurView的y位置变为0,这个动画从下向上移动。如何从中心向外移动。
    • 你能解释一下从中心向外是什么意思吗?你的意思是扩大并变得不可见?
    • 我正在为 blurView 寻找径向动画
    • 我还是没听懂你,如果你能链接一个类似动画的视频,我很乐意做!
    【解决方案2】:

    通过使用 UIView 动画

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

    【讨论】:

      【解决方案3】:

      如果你想维护框架:

        [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 个像素。

      【讨论】:

      • 感谢您的回复,但我必须从中心到径向向外做不可见的模糊视图。
      • 将视图的 .alpha 值更改为零,请参阅更新。
      • 你想让它从内向外淡出吗?例如,视图的中间是不可见的,并且向边缘蔓延?
      • 是的,子视图将从内向外动画,但不应淡出。它应该从中间移除并爬向超级视图的边缘,以便超级视图清晰可见。
      猜你喜欢
      • 1970-01-01
      • 2018-09-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-24
      • 2018-08-24
      相关资源
      最近更新 更多