码迷,mamicode.com
首页 > 其他好文 > 详细

UIBezierPath叠加的相加相减显示

时间:2019-11-21 17:10:21      阅读:122      评论:0      收藏:0      [点我收藏+]

标签:wpa   for   erp   width   ram   div   add   int   close   

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

 

UIBezierPath叠加的相加相减显示

标签:wpa   for   erp   width   ram   div   add   int   close   

原文地址:https://www.cnblogs.com/yuxiaoyiyou/p/11906384.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!