Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/22.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
Objective c iOS 10如何设置UIVisualEffectView maskView的UIBezierPath动画_Objective C_Ios10_Xcode8_Uibezierpath - Fatal编程技术网

Objective c iOS 10如何设置UIVisualEffectView maskView的UIBezierPath动画

Objective c iOS 10如何设置UIVisualEffectView maskView的UIBezierPath动画,objective-c,ios10,xcode8,uibezierpath,Objective C,Ios10,Xcode8,Uibezierpath,我刚刚更新到Xcode 8,在iOS 10上遇到了模糊(UIVisualEffectView)问题,但我解决了这个问题。但在我修复了模糊层遮罩后,第二个问题出现了,当我从UIVisualEffectView获取maskView的引用并应用新的UIBezierPath时,什么也没有发生 代码示例: -(void)prepareEffectView{ //Frame CGRect frame = self.view.bounds; UIView *maskView = [

我刚刚更新到Xcode 8,在iOS 10上遇到了模糊(UIVisualEffectView)问题,但我解决了这个问题。但在我修复了模糊层遮罩后,第二个问题出现了,当我从UIVisualEffectView获取maskView的引用并应用新的UIBezierPath时,什么也没有发生

代码示例:

-(void)prepareEffectView{

    //Frame
    CGRect frame = self.view.bounds;

    UIView *maskView = [[UIView alloc] initWithFrame:frame];
    maskView.backgroundColor = [UIColor blackColor];

    maskView.layer.mask = ({ // This mask draws a rectangle and crops a circle inside it.

        UIBezierPath *maskLayerPath = [UIBezierPath bezierPath];
        [maskLayerPath appendPath:[UIBezierPath bezierPathWithRect:frame]];
        [maskLayerPath appendPath:[UIBezierPath bezierPathWithRect:CGRectMake(self.btnScan.center.x, self.btnScan.center.y, 0, 0)]];
        [maskLayer setPath:maskLayerPath.CGPath];
        [maskLayerPath setUsesEvenOddFillRule:YES];

        CAShapeLayer *mask = [CAShapeLayer layer];
        mask.path     = maskLayerPath.CGPath;
        mask.fillRule = kCAFillRuleEvenOdd;
        mask;
    });

    self.visualEffectView.maskView = maskView;
}


-(void)openAperture{

  //Blur layer
  CGRect frame = self.view.bounds;
  CAShapeLayer *maskLayer = (CAShapeLayer *)self.visualEffectView.maskView.layer.mask;


  //New path value
  UIBezierPath *maskLayerPath = [UIBezierPath bezierPath];
  [maskLayerPath appendPath:[UIBezierPath bezierPathWithRect:frame]];
  [maskLayerPath appendPath:[UIBezierPath bezierPathWithRoundedRect:UIEdgeInsetsInsetRect(frame, UIEdgeInsetsMake(58, 15, 66, 15)) cornerRadius:1]];
  [maskLayer setPath:maskLayerPath.CGPath];


  //Animation
  CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"path"];
  animation.delegate = self;
  animation.duration = 0.44;
  animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
  animation.fromValue = (id)maskLayer.path;
  animation.toValue = (id)maskLayerPath.CGPath;
  [maskLayer addAnimation:animation forKey:@"animatePath"];

}

我也有同样的问题

我试着做下一步:(Swift代码)

而不是
visualEffectView.mask=maskView

如果是这样,路径动画可以正常工作,但是模糊效果消失了

如果你找到了解决方案,请更新帖子

苹果关于iOS 10上VisualEffectView问题的说明

在这个领域,过渡是艰难的,因为maskView是实现这一目标的唯一途径 确保效果有效,但maskView也不可设置动画

将“CAShapeLayer”用作遮罩的唯一方法是将形状应用于UIView.layer.mask,然后将其应用于UIVisualEffectView.maskView

UIVisualEffectView的maskView不可设置动画

visualEffectView.layer.mask = maskView.layer.mask