티스토리 뷰
728x90
출처 : Freehand drawing on iOS in Swift - Ilya Puchka
override func touchesBegan(_ touches: Set<uitouch>, with event: UIEvent?) { if let touch = touches.first { messageLabel.text = "touchesBegan" tapCountLabel.text = String(touch.tapCount) touchCountLabel.text = String(touches.count) lastPoint = touch.location(in: drawImageView) } } override func touchesMoved(_ touches: Set<uitouch>, with event: UIEvent?) { if let touch = touches.first { messageLabel.text = "touchesMoved" tapCountLabel.text = String(touch.tapCount) touchCountLabel.text = String(touches.count) lineWidth = CGFloat(Int(textLineWidth.text!)!); UIGraphicsBeginImageContext(drawImageView.frame.size) if let context = UIGraphicsGetCurrentContext() { context.setLineWidth(lineWidth) context.setStrokeColor(lineColor) context.setLineCap(CGLineCap.round) drawImageView.image?.draw(in: CGRect(origin: CGPoint(x : 0, y : 0), size: drawImageView.frame.size)) context.move(to: lastPoint) let currentPoint = touch.location(in: drawImageView) context.addLine(to : currentPoint) context.strokePath() drawImageView.image = UIGraphicsGetImageFromCurrentImageContext() lastPoint = currentPoint } UIGraphicsEndImageContext() } } override func touchesEnded(_ touches: Set<uitouch>, with event: UIEvent?) { if let touch = touches.first { messageLabel.text = "touchesEnded" tapCountLabel.text = String(touch.tapCount) touchCountLabel.text = String(touches.count) } }
댓글
300x250
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
TAG
- KOBA
- koba2010
- Spring MVC
- sas2009
- android
- 레이싱모델 익스트림 포토 페스티벌
- 일본여행
- Delphi Tip
- 송주경
- NDK
- ffmpeg
- 서울오토살롱
- 전예희
- BPI-M4
- SAS
- Java
- Linux
- Delphi
- 튜닝쇼 2008
- 지스타2007
- ble
- oracle
- ubuntu
- Spring
- flex
- JavaScript
- 동경
- Xcode
- Mac
- MySQL
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
글 보관함