![这里写图片描述](https://img-blog.csdn.net/20151007213747796)
![这里写图片描述](https://img-blog.csdn.net/20151007213833079)
- (void)showMask {
[UIApplication sharedApplication].keyWindow.backgroundColor = [UIColor redColor]
CALayer *maskLayer = [CALayer layer]
maskLayer.contents = (__bridge id _Nullable)([UIImage imageNamed:@"mask"].CGImage)
maskLayer.position = self.view.center
maskLayer.bounds = CGRectMake(0, 0, 100, 100)
self.navigationController.view.layer.mask = maskLayer
CAKeyframeAnimation *anim = [CAKeyframeAnimation animationWithKeyPath:@"bounds"]
anim.duration = 2
anim.beginTime = CACurrentMediaTime()
anim.delegate = self
NSValue *initBounds = [NSValue valueWithCGRect:CGRectMake(0, 0, 100, 100)]
NSValue *middleBounds = [NSValue valueWithCGRect:CGRectMake(0, 0, 80, 80)]
NSValue *finalBounds = [NSValue valueWithCGRect:CGRectMake(0, 0, 2000, 2000)]
anim.values = @[initBounds,middleBounds,finalBounds]
anim.keyTimes = @[@0, @0.5, @1]
anim.timingFunctions = @[[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut],[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]]
anim.removedOnCompletion = NO
anim.fillMode = kCAFillModeForwards
[self.navigationController.view.layer.mask addAnimation:anim forKey:nil]
}
- (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag {
self.navigationController.view.layer.mask = nil
}