Wie kann ich das Innere des UIBezier-Pfades farbig gestalten? Ich mache ein einfaches Dreieck und möchte innerhalb des Dreiecks mit roter Farbe färben.UIBezierPath in Swift archivieren
class GraphView : UIView {
override func drawRect(rect: CGRect) {
UIColor.redColor().setFill()
UIColor.greenColor().setStroke()
let path = UIBezierPath(rect: rect)
path.moveToPoint(CGPointMake(100,620))
path.addLineToPoint(CGPointMake(300,100))
path.addLineToPoint(CGPointMake(500,620))
path.addLineToPoint(CGPointMake(100,620))
path.closePath()
path.fill()
path.stroke()
}
}
let graphView = GraphView(frame: CGRectMake(0,0,960,640))
XCPlaygroundPage.currentPage.liveView = graphView
Der obige Code wird auf dem Spielplatz geschrieben: Hier ist das Ergebnis:
Tut mir leid! Die Frage wurde mit Code und neuem Screenshot aktualisiert. –