iOS mask 层 UIBezierPath path 放大
//
// ViewController.m
// test_shapeLayer_02
//
// Created by admin on 3/4/16.
// Copyright © 2016 jeffasd. All rights reserved.
//
#import "ViewController.h"
@interface ViewController ()
@property(nonatomic, strong)CAShapeLayer *makeLayer;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
_makeLayer = [CAShapeLayer layer];
UIView *view = [UIView new];
// view.frame = CGRectMake(100, 100, 50, 50);
view.frame = self.view.frame;
view.backgroundColor = [UIColor redColor];
[self.view addSubview:view];
UIBezierPath *path = [UIBezierPath bezierPathWithRect:CGRectMake(0, 0, 0, 0)];
_makeLayer.path = path.CGPath;
[_makeLayer removeFromSuperlayer];
view.layer.mask = _makeLayer;
[UIView animateWithDuration:(3.0) animations:^{
// _makeLayer.frame = self.view.frame;
}];
// //让圆的变大的动画
// CABasicAnimation *pathAnimation = [CABasicAnimation animationWithKeyPath:@"path"];
// UIBezierPath *toPath = [self pathWithDiameter:self.bigDiameter];
// // UIBezierPath *toPath = [self pathWithDiameter:0];//缩小当前path的动画
// pathAnimation.toValue = (id)toPath.CGPath;
// pathAnimation.duration = 1.0;
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"path"];
animation.toValue = (id)[UIBezierPath bezierPathWithRect:self.view.frame].CGPath;
animation.duration = 0.5;
animation.delegate = self;
animation.removedOnCompletion = NO;
animation.fillMode = kCAFillModeForwards;
// [view.layer addAnimation:animation forKey:@"11"];
[_makeLayer addAnimation:animation forKey:@"21"];
// _makeLayer.
// UIBezierPath *bPath = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(200, 100, 100, 100)];
// bPath.usesEvenOddFillRule = YES;
// UIBezierPath *bsPath = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(220, 120, 60, 60)];
// [bPath appendPath:bsPath];
// [bPath addClip];
}
//- (UIBezierPath *)pathWithDiameter:(CGFloat)diameter {
// return [UIBezierPath bezierPathWithOvalInRect:CGRectMake((CGRectGetWidth(self.bounds) - diameter) / 2, (CGRectGetHeight(self.bounds) - diameter) / 2, diameter, diameter)];
//}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end