# coregraphics

Published articles for coregraphics.

This is one page of public article previews, not the complete archive. Follow Next page to continue. Summaries are not the original full articles.

## Drawing icons using Core Graphics

DevFeed: [Drawing icons using Core Graphics](<https://devfeed.tech/articles/drawing-icons-using-core-graphics-35096.md>)

Original publisher: [Read original article](<https://engineroom.teamwork.com/drawing-icons-using-core-graphics-fed30458f2ed?source=rss----cea4eecd5960---4>)

Author: Diego Freniche

Published: 2020-10-20T09:14:19Z

Content type: tutorial

Language: en

Sources: [Teamwork](<https://devfeed.tech/sources/teamwork.md>)

Topics: [Graphics](<https://devfeed.tech/topics/graphics.md>), [Code](<https://devfeed.tech/topics/code.md>), [iOS](<https://devfeed.tech/topics/ios.md>), [App](<https://devfeed.tech/topics/app.md>)

Tags: [code](<https://devfeed.tech/tags/code.md>), [coregraphics](<https://devfeed.tech/tags/coregraphics.md>), [graphics](<https://devfeed.tech/tags/graphics.md>), [ios](<https://devfeed.tech/tags/ios.md>), [playground](<https://devfeed.tech/tags/playground.md>), [swift](<https://devfeed.tech/tags/swift.md>), [swift-playgrounds](<https://devfeed.tech/tags/swift-playgrounds.md>), [uikit](<https://devfeed.tech/tags/uikit.md>)

### AI overview

A hands-on tutorial that uses Core Graphics in an iOS Playground to recreate a notebook icon from rectangles. It explains why vector-based drawing avoids the pixelation of bitmap icons and demonstrates the setup and initial implementation in code.

### Source excerpt

Photo by Harpal Singh on Unsplash Sometimes you need to add an icon to your iOS app, The designer sends you that plain, simple icon. It can be a bitmap-based icon, like a PNG. Problem with those is they get blurry if zoomed in too much. So we can use a vector-based icon, like a Font Icon or a PDF. These are vector based, contains the instructions to draw the icon, not the icon itself. This way you can stretch the icon as much as you want, and you'll never see "big pixels" in your app. But what happens when you have a screen capture of your icon, but can't get any of these options? Well, this means it's time to dust-off your Core Graphics Skills and draw the icon by yourself. Won't even mention the horrible alternative of taking a screenshot and cutting the icon. Don't do it. I've done it and it's, indeed, horrible. Instead of telling you what Core Graphics is and how it works, we'll write code to solve a problem, so you can experiment and learn by doing. This is my preferred way of learning a new framework / library / language: try things, read a bit, try more stuff, read more seriously, watch videos, GOTO 1. The Notebook Icon The icon we'll try to recreate is this one: Represents a notebook with a background color that can change, a darker same color spine and a couple lines to represent the Notebook title. Create a new Playground We'll do all our coding inside a Playground. So we can get instant feedback. In the end, it will look like this: But for now let's create a Playground called Icons. It will just have one Playground page. Remove everything inside that page and just add: https://medium.com/media/b3fbc322df52879b716e63ffdfa765e0/href We'll use the first import to draw Views and use Core Graphics (it's included by UIKit). PlaygroundSupport will help us show nice previews of our work inside the Playground. Planning our work Looking at that notebook icon we can see it's composed of 4 rectangles: a big rectangle that forms the Notebook itself a spine rectangle a