LoginSignup
0
0

More than 5 years have passed since last update.

[SWIFT4]お絵描きペイントペンの色変え方法

Last updated at Posted at 2019-06-27

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を表示し、そこで色を選択して前の画面に戻ると
ペンの色が選択した状態にするのが目標です。

ご教授いただけると助かります

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0