swiftの学習を始めてペイントツールを作成しているのですが、
ペンの色を変える事ができません。
// 描画処理
func drawLine(path:UIBezierPath){
UIGraphicsBeginImageContext(canvas.frame.size)
if let image = self.lastDrawImage {
image.draw(at: CGPoint.zero)
}
let lineColor = UIColor.blue // blueをデフォルトに設定
lineColor.setStroke()
path.stroke()
self.canvas.image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
}
最初の指定はできるのですが、色変更ボタンを設置してblackやredに変更したいのです。
描画はできています。
ボタンで別Viewを表示し、そこで色を選択して前の画面に戻ると
ペンの色が選択した状態にするのが目標です。
ご教授いただけると助かります