2010-10-03 46 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); 
}