PaintCode Sketch Plugin Tutorial

Learn how to use the new PaintCode Sketch plugin to export your Sketch artwork into Swift code, allowing easy resizing and dynamic customization. By Robert Chen.

Leave a rating/review
Save for later
Share
You are currently viewing page 4 of 4 of this article. Click here to view the first page.

Wire up the switch

All that’s left is to wire up the UISwitch in the order form.

Open OrderViewController.swift and replace the toggleBubbles @IBAction method with the following:

@IBAction func toggleBubbles(sender: UISwitch) {
  bubbleTeaCup.bubbles = sender.on
}

This updates the bubbles flag whenever the UISwitch is toggled.

Build and run. Now when you toggle the switch, the bubbles in the order preview image should disappear.

Toggles bubbles, flavor, and size

Pretty cool! Play around a bit and think back on all you’ve accomplished:

  • You’ve taken a cool illustration designed in Sketch…
  • …used the new PaintCode Sketch plugin to auto-generate Core Graphics code for that illustration…
  • …which results in smaller binary size, scalability, and the ability to dynamically customize the image at runtime!

Where To Go From Here?

You can download the final project which includes the Xcode project and Sketch file here.

To learn more about the PaintCode plugin, check out the tutorials on the official site.

If you need to dig deeper into Core Graphics, this tutorial is a good place to start. And if you don’t use Sketch but still like what the PaintCode plugin can do, consider whether PaintCode 2 is right for you.

We hope you enjoyed this tutorial, and if you have any questions or comments, please join the discussion below!

Robert Chen

Contributors

Robert Chen

Author

Over 300 content creators. Join our team.