UIBezierパスの内部をどのように色付けできますか?私は単純な三角形を作っていて、三角形の内部を赤色で色付けしたいと思っています。SwiftでUIBezierPathを登録する
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
上記のコードは、遊び場で書かれている:ここでの結果である:
申し訳ございません。コードと新しいスクリーンショットで質問を更新しました。 –