Arbitrary Drawing with Playground

Quang Quoc Tran
2 min readFeb 23, 2019

--

If this post is useful, please support me by trying my free Animal 5D app. Animal 5D uses AR tech to teach children to know animals. This app helps children to have physical activities to create health and more interested in learning. Check It Out!

To draw somethings on UIView, you need to override draw method of UIView and get current context.

I use Playground to test drawing commands quickly. So you need to create a new Playground too.

View the code of following samples, paste them into Playground and run it. Editing some parameters of the code to know how it works.

You can also download Playground file here.

1. Fill background color

2. Fill an Ellipse

3. Fill a Path

4. Fill an Arc

5. Stroke a Curve

6. Draw a Linear Gradient

7. Draw a Radial Gradient

That’s all. You can download Playground file here.

If this post is useful, please support me by trying my free Animal 5D app. Animal 5D uses AR tech to teach children to know animals. This app helps children to have physical activities to create health and more interested in learning. Check It Out!

--

--