zoukankan      html  css  js  c++  java
  • UIBezierPath叠加的相加相减显示

    -(void)addBlankFrames:(NSArray<__kindof NSValue *> *)frames {
        UIBezierPath *path = self.blankPath?:[UIBezierPath bezierPath];
        CGRect oldRect = CGRectZero;
        for (NSValue *value in frames) {
            CGRect frame = [value CGRectValue];
            UIBezierPath *p = [UIBezierPath bezierPathWithRect:frame];
            if (oldRect.size.width > 0 && oldRect.size.height > 0) {
                [p appendPath:[[UIBezierPath bezierPathWithRect:CGRectIntersection(frame, oldRect)] bezierPathByReversingPath]];
            }
            [path appendPath:p];
    
            oldRect = frame;
        }
        [path closePath];
        self.blankPath = path;
        UIBezierPath *showPath = [UIBezierPath bezierPathWithRect:self.blackLayer.bounds];
        [showPath appendPath:[self.blankPath bezierPathByReversingPath]];
        [self.blackLayer setPath:showPath.CGPath];
    }
    
    -(void)hideNoBlankFrames:(NSArray<__kindof NSValue*> *)frames {
        UIBezierPath *path = self.blankPath?:[UIBezierPath bezierPath];
        for (NSValue *value in frames) {
            CGRect frame = [value CGRectValue];
            UIBezierPath *p = [UIBezierPath bezierPathWithRect:frame];
            [path appendPath:p];
            [path appendPath:p];
        }
        [path closePath];
        self.blankPath = path;
        UIBezierPath *showPath = [UIBezierPath bezierPathWithRect:self.blackLayer.bounds];
        [showPath appendPath:[self.blankPath bezierPathByReversingPath]];
        [self.blackLayer setPath:showPath.CGPath];
    }
  • 相关阅读:
    Linux安装Docker
    Api接口防攻击防刷注解实现
    Api接口鉴权注解实现
    RSA加解密 Java
    Windows安装Mysql 5.7
    Mysql创建自增序列
    new String与toString的区别
    各排序算法复杂度及稳定性
    描述快排以及其复杂度
    innodb和myisam的区别
  • 原文地址:https://www.cnblogs.com/yuxiaoyiyou/p/11906384.html
Copyright © 2011-2022 走看看