Performing custom bitmap drawing in an iOS application
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.
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);
}
精彩评论