SKCore – A Simplification Toolset (Core Graphics, Autolayout and more)

What is SKCore?

SKCore is a set of classes and categories created to simplify layout and drawing in code. The objective of SKCore is to take underlying technologies and make simple wrappers around them to reduce the amount of code needed.

SKCore GitHub Repo

Drawing

One of the most powerful things that SKCore simplifies is drawing with Core Graphics. Some of the messiest code I have come across is drawing code. Part of the reason for this, is that it is written in C instead of Objective-C and C tends to get verbose. SKCore offers some simple Objective-C wrappers that can make drawing code a lot easier to read, maintain and update. A good use case for this is to create a generic button skin that can be used across your app without the need to include an image asset. This is useful when the design for something is simple to recreate in code. Small design tweaks and color changes can then be as simple as changing a hex value or measurement variable. Below is a link to a gist that demonstrates how to make a stretchable button skin with SKCore. The resulting output can be seen in the image below.

View Drawing Code

SKCore_Button

Layout

SKCore has a set of categories to simplify the management and creation of Auto Layout constraints. The main problem with Auto Layout, in my opinion, is the verbose nature of the methods used to create constraints. Below is an example which shows the code needed for the layout of a screen using default methods. It also shows the SKCore alternative. Both ways used the exact same VFL strings to create the layout. The SCKore version cuts the code down from 2,058 characters to just 582. The result can be seen in the image below.

Auto Layout Comparison Code

SKCore_Layout

One thought on “SKCore – A Simplification Toolset (Core Graphics, Autolayout and more)”

Leave a Reply

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