iOS mask 层 UIBezierPath path 放大

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


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值