views:

43

answers:

1

I am new to iOS/Mac programming. I am trying to create an iOS application that performs custom bitmap drawing, and blits it to screen.

I have looked at some examples that use CGImage, but I haven't been able to able to follow them to create an iOS application that performs custom drawing on the application window.

I am now looking for examples/tutorials related to this, written specifically for iOS. Please post any you know of.

A: 

Create a subclass of UIView and implement the drawRect: method. Drawing to a Graphics Context in iOS

Drawing a red rectangle:

...with Quartz

- (void)drawRect:(CGRect)rect {
  CGContextRef context = UIGraphicsGetCurrentContext();
  CGContextSetRGBFillColor(context, 1.0,0.0,0.0,1.0);
  CGRect rectangle = CGRectMake(10, 10, 50, 50);
  CGContextFillRect(context, rectangle);
}

...with UIKit

- (void)drawRect:(CGRect)rect {
  [[UIColor redColor] set];
  CGRect rectangle = CGRectMake(10, 10, 50, 50);
  UIRectFill(rectangle); 
}
Jason Harwig