UIView 不规则剪裁


    CGSize size = _titleShapeView.frame.size;
    CAShapeLayer *shapeLayer = [CAShapeLayer layer];
    [shapeLayer setFillColor:[[UIColor redColor] CGColor]];
    
    CGMutablePathRef path = CGPathCreateMutable();
    CGPathMoveToPoint(path, NULL, .0f,.0f);
    CGPathAddLineToPoint(path, NULL, size.width-(size.height-2), 0.0);
    CGPathAddLineToPoint(path, NULL, size.width, size.height-2);
    CGPathAddLineToPoint(path, NULL, 0.0, size.height-2);
    CGPathCloseSubpath(path);
    [shapeLayer setPath:path];
    CFRelease(path);
    _titleShapeView.layer.mask = shapeLayer;



你可能感兴趣的:(UIView 不规则剪裁)