FishPaint is a lightweight framework that offers a paint view for user written in Swift. FishPaint is built by using Core Gaphics.
- iOS 8.0+
- Xcode 8.0+
- Swift 3.0
FishPaint is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "fishPaint"
Simply copy the contents of the 'Class' folder into your project.
Simply create a fishPaintView and add it to your View Controller:
let paintView = fishPaintView(frame: self.view.frame)
self.view.addSubview(paintView)
By default, the view will automatically respond to touch gestures and begin drawing. The default line color is black.
You can customization the properties for the fishPaintView, like drawingEnabled
,lineWidth
,lineOpacity
,lineColor
:
paintView.drawingEnabled = false
paintView.lineWidth = CGFloat(12.0)
paintView.lineOpacity = CGFloat(1.0)
paintView.lineColor = UIColor.white
FishPaint can let user to delete the last line segment. Simply call the removeLastLine
function:
paintView.removeLastLine()
If you wish to clear the whole canvas, simply call the clearCanvas
function:
paintView.clearCanvas()
FishPaint offers delegate functions to response user's reaction with a fishPaintView. To access these delegate methods, simply add your View Controller as the fishPaintViewDelegate
:
class ViewController: UIViewController, fishPaintViewDelegate
There are four optional delegate methods:
func fishPaintDidBeginDrawing(view: fishPaintView)
func fishPaintIsDrawing(view: fishPaintView)
func fishPaintDidFinishDrawing(view: fishPaintView)
func fishPaintDidCancelDrawing(view: fishPaintView)
FishPaint is available under the MIT license. See the LICENSE file for more info.