Tuesday, July 14, 2009

Monday, July 13, 2009

Quartz 2D and Core Graphics

Drawing in Cocoa is usually accomplished with the help of the Quartz 2D API which is part of the Core Graphics framework.

iPhone Blog





Sunday, July 12, 2009

iPhone App: Amazing Polygon App - update 2 simple shape

I have begun playing with some of the CG libraries available on the iPhone. It is more C-like than I had expected but still pretty straightforward.

You can see below there is a gray area at the lower portion of the screen which is actually a subclass of UIView. It has a drawRect call that is invoked by the Graphics System when the main window of the application is initialized.

UIView Structures


  • CGPoint (x,y)
  • CGSize (width, height)
  • CGRect (origin + size, or CGPoint + CGSize)
Note the origin point is the upper-left hand corner (0,0)
X positive goes to the right
Y positive goes down

Creating CG objects:
CGPoint point = CGPointMake(50.0,100.0);
point.x = 50.0
point.y = 100.0

CGSize size = CGSizeMake(23.0,42.0);
size.width = 23.0;
size.height = 42.0;

CGRect rect = CGRectMake( x, y, width, height);
rect.origin.x = x1;
rect.origin.y = y1;
rect.size.width = w1;
rect.size.height = h1;




iPhone UIView

Some of this is directly from the Stanford series

UIView is part of UIKit Framework which is part of Cocoa.

It represents a rectangular part of the screen. With it you can:
  • draw into the rectangular area
  • process events (since it inherits from UIResponder)
View Hierarchies:
  • every view has ONE superview (assuming the view has been put into another view)
  • every view has ZERO or MORE subviews
UIWindow is a subclass of UIView

NOTE: there is only one UIWindow for an iPhone App


Finished Lecture 3 and 4

Making some progress.

Getting the hang of Objective-C, XCode and Interface Builder.