InkKit – Swift Library That Simplifies Many Common Graphics Related Tasks Such As Gradient Fills

InkKit from Shaps M is a Swift based library simplifying many common drawing related tasks.

  • Simplified draawing of lines, paths, and fills
  • Filling graphical objects with gradients
  • Drawing images with simple scaling, alignment and blending options
  • Drawing of text with easy alignment to
  • Geometry utility functions

This code snippet from the readme shows how one could draw a gradient filled rectangle with text and a circle:

let (leftRect, rightRect) = frame.divide(atDelta: 0.5, fromEdge: .MinXEdge, margin: 10)
let start = Color.whiteColor()
let end = Color.blackColor()
let leftPath = BezierPath(rect: leftRect)

// fill the left rect with a 90º gradient
Draw.fillPath(leftPath, startColor: start, endColor: end, angleInDegrees: 90)

// draw some text, aligned to the right rect
"InkKit is so awesome!".drawAlignedTo(rightRect, horizontal: .Center, vertical: .Middle)

// create an image of a circle (with a radius of 5pt) and draw it
Image.circle(radius: 10) { (attributes) in
  attributes.strokeColor = Color.blackColor()
  attributes.fillColor = Color.redColor().colorWithAlphaComponent(0.5)
  attributes.dashPattern = [1, 4]
  attributes.lineWidth = 2
}.drawAtPoint(CGPointMake(0, 0))

You can find InkKit on Github here.

A nice graphics helper library.

Original article: InkKit – Swift Library That Simplifies Many Common Graphics Related Tasks Such As Gradient Fills

©2016 iOS App Dev Libraries, Controls, Tutorials, Examples and Tools. All Rights Reserved.

Leave a Reply

Your email address will not be published. Required fields are marked *