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;
转载于:https://my.oschina.net/u/2339850/blog/535467