2010-10-03 48 views
2

我是iOS/Mac编程的新手。我正在尝试创建一个执行自定义位图绘制的iOS应用程序,并将其屏蔽。在iOS应用程序中执行自定义位图绘图

我看过一些使用CGImage的示例,但我无法按照它们来创建在应用程序窗口上执行自定义绘图的iOS应用程序。

我现在正在寻找与此相关的示例/教程,专门为iOS编写。请张贴你知道的任何信息。

回答

0

创建UIView的子类并实现drawRect:方法。 Drawing to a Graphics Context in iOS

画一个红色矩形:

...与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); 
} 

...与UIKit

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