I know that there is a roundedRect drawing method - UIBezierPath(roundedRect, cornerRadius)
But I would like to know if I can fix this corner myself, why should I add addClip before drawing a rectangle? (I feel like we are squeezing a rectangle after it has been drawn more intelligently. What concept did I miss?)
(1) work
override func drawRect(rect: CGRect) { var clipPath = UIBezierPath(roundedRect: rect, cornerRadius: 8.0) path.addClip() var rectPath = UIBezierPath(rect: rect) UIColor.redColor().setFill() rectPath.fill() }
(2) does not work
override func drawRect(rect: CGRect) { var rectPath = UIBezierPath(rect: rect) UIColor.redColor().setFill() rectPath.fill() var clipPath = UIBezierPath(roundedRect: rect, cornerRadius: 8.0) path.addClip() }
Jenny source share