Drawing in Obj-C: Lines and Circles

Day 14

In a previous post I showed an example of creating a custom view in which I drew a triangle on screen. I thought I’d spend a bit of time taking a closer look at the code and demonstrate how to draw simple shapes in Objective-C.

Example 1: Lines

The following will draw a triangle in the view with green fill and a red stroke. I’ve added a bunch of comments to each line to make it clear what is happening. Keep reading →

Custom Sub Views

Day 11

Placing and drawing UIView objects using the Object Library works a lot of the time, but there are instances where you’ll need to create your own custom views. A sub view is just a UIView object placed within a parent view. They can be created through the GUI by dragging out an object such as a button or label, or programatically.

There are two common reasons why you’d want to create a custom sub view:

  1. You want create a custom drawing on the screen; or
  2. You want to handle touch events in a way different from the defaults
I’m creating this using a new, single-view application project. Keep reading →