2017-09-02 5 views
0

現在、私は小さな問題を抱えています。下のコードは、私のtableViewHeaderの上に三角形のレイヤーを出力しますが、bazierパスのカット方向を反転したいと思います。UIBezierPath Triangle reverse

コード:

let cutDirection = UIBezierPath() 
cutDirection.move(to: CGPoint(x: 0, y: 0)) 
cutDirection.addLine(to: CGPoint(x: headerRect.width, y: 0)) 
cutDirection.addLine(to: CGPoint(x: headerRect.width, y: headerRect.height)) 
cutDirection.addLine(to: CGPoint(x: 0, y: headerRect.height - headerCut)) 
newHeaderLayer.path = cutDirection.cgPath 

出力:私は探しています

enter image description here

enter image description here

結果:

ありがとうございました!

ケビン。

+0

あなたの質問は何ですか? – rmaddy

+0

@rmaddyカットディレクションを逆にしたい。既に修正済み! –

+0

あなたが望むのははっきりしていました。しかしあなたの質問はそうではありませんでした。 – rmaddy

答えて

0

このお試しください:私はこれを正しく従った場合は、以下を交換する必要があり

let cutDirection = UIBezierPath() 
cutDirection.move(to: CGPoint(x: 0, y: 0)) 
cutDirection.addLine(to: CGPoint(x: headerRect.width, y: 0)) 
cutDirection.addLine(to: CGPoint(x: headerRect.width, y: headerRect.height - headerCut)) 
cutDirection.addLine(to: CGPoint(x: 0, y: headerRect.height)) 
newHeaderLayer.path = cutDirection.cgPath 
0

を:

cutDirection.addLine(to: CGPoint(x: headerRect.width, y: headerRect.height)) 
cutDirection.addLine(to: CGPoint(x: 0, y: headerRect.height - headerCut)) 

へ:それを古い学校の方法を行うことによって、それを修正

cutDirection.addLine(to: CGPoint(x: 0, y: headerRect.height - headerCut)) 
cutDirection.addLine(to: CGPoint(x: headerRect.width, y: headerRect.height)) 
0

: 紙の上に!

ソリューション:

let cutDirection = UIBezierPath() 
cutDirection.move(to: CGPoint(x: 0, y: 0)) 
cutDirection.addLine(to: CGPoint(x: headerRect.width, y: 0)) 
cutDirection.addLine(to: CGPoint(x: headerRect.width, y: headerRect.height - headerCut)) 
cutDirection.addLine(to: CGPoint(x: 0, y: headerRect.height)) 
cutDirection.close() 
newHeaderLayer.path = cutDirection.cgPath