This is the Simple Example. In this example we will see how to draw rectangle in the window base application.
Step 1: Create a Window base application using template. Give the application name “RectDraw”.
Step 2: Xcode automatically creates the directory structure and adds essential frameworks to it. You can explore the directory structure to check out the content of the directory.
Step 3: Open the RectDrawAppDelegate.m file and make the following changes in the file:
window.backgroundColor = [UIColor blackColor];
CGRect redFrame = CGRectMake(20, 20, 100, 100);
UIView *redView = [[UIView alloc] initWithFrame:redFrame];
redView.backgroundColor = [UIColor redColor];
[window addSubview:redView];
[redView release];
CGRect yellowFrame = CGRectMake(120, 120, 100, 100);
UIView *yellowView = [[UIView alloc] initWithFrame:yellowFrame];
yellowView.backgroundColor = [UIColor yellowColor];
[window addSubview:yellowView];
[yellowView release];
CGRect blueFrame = CGRectMake(220, 220, 100, 100);
UIView *blueView = [[UIView alloc] initWithFrame:blueFrame];
blueView.backgroundColor = [UIColor blueColor];
[window addSubview:blueView];
[blueView release];
[window makeKeyAndVisible];
return YES;
}
Step 4: Now compile and run the application in the Simulator.
You can Download SourceCode from here RectDraw












Good article, nice and simple.