Draw transparent UIBezierPath line inside drawRect
问题 I am trying to achieve a transparency path in the drawRect method. This is the simple code I have created: override func drawRect(rect: CGRect) { let clippingPath = UIBezierPath() UIColor.whiteColor().set(); clippingPath.moveToPoint(CGPoint(x: 10, y: CGRectGetHeight(self.bounds) / 2)) clippingPath.addLineToPoint(CGPoint(x: CGRectGetWidth(self.bounds) - 10, y: CGRectGetHeight(self.bounds) / 2)) clippingPath.lineWidth = 6 clippingPath.lineCapStyle = .Round clippingPath.stroke() } And this is