2016-10-06 3 views
1

Я только что обновился до Xcode 8, и у меня была проблема с Blur (UIVisualEffectView) на iOS 10, но я решаю его. Но после того, как я исправил маску слоя размытия, появляется вторая проблема, когда я получаю ссылку maskView из UIVisualEffectView и применяю новый UIBezierPath, ничего не происходит.iOS 10 Как оживить UIBezierPath UIVisualEffectView maskView

Пример кода:

-(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"]; 

} 

ответ

0

У меня такая же проблема.

Я попытался сделать следующее: (Swift код)

visualEffectView.layer.mask = maskView.layer.mask 

visualEffectView.mask = maskView вместо

Если да, то путь анимации отлично работает, но затем эффект размытия ушел.

Если вы нашли решение, пожалуйста, обновите сообщение.

1

компании Apple Примечание О VisualEffectView вопроса прошивки 10

Переходы жестки в этой области, так как maskView это единственный способ гарантировать, что эффект работает, но maskView также не анимируемая.

https://forums.developer.apple.com/message/184810#184810

Единственный способ использовать «CAShapeLayer» в качестве маски, чтобы применить форму UIView.layer.mask, а затем положить его в UIVisualEffectView.maskView.

Маскирование UIVisualEffectView не является анимированным.

Смежные вопросы