So che c'è un metodo per disegnare una roundedRect - UIBezierPath(roundedRect, cornerRadius)
UIBezierPath addClip e drawRect
Ma vorrei sapere se ho clip l'angolo da me, perché dovrei avere a addClip prima di disegnare un rettangolo? (Mi sento come clip di rettangolo dopo che è stato pareggio è più ragionevole. Che concetto mi sono perso?)
(1) lavoro
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) non funziona
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()
}
oh ~ ottima risposta! Grazie :) – Jenny