#import <UIKit/UIKit.h>
@interface quartzViewController : UIViewController {
IBOutlet UIView *myView;
}
@end
#import "quartzViewController.h"
@implementation quartzViewController
-(void)drawRect:(CGRect)rect
{
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSelectFont(context, "Arial", 24, kCGEncodingFontSpecific);
CGContextSetTextPosition(context,80,80);
CGContextShowText(context, "hello", 6);
//not even this works
CGContextShowTextAtPoint(context, 1,1, "hello", 6);
}
- (void)viewDidLoad {
[myView setNeedsDisplay];
[super viewDidLoad];
}
我需要對筆尖進行任何更改嗎?爲什麼drawRect方法沒有被調用?
由於
是啊thanx的答覆,我有我的答案,你是對的,我帶了一個新的類,我從UIVIEW繼承,我發現drawRect方法,這不叫... – Rahul 2010-05-12 07:16:55
如果你有答案,那麼你應選擇他們接受。你可以閱讀FAQ。 – harshalb 2010-09-16 09:35:13