我正在尝试学习石英的基础知识,但不明白为什么这不起作用-当按下按钮时,这应该将红色矩形向右移动,在瞬间击球,它什么也没做-“NSLog(A "help"); 是试图弄清楚按钮是否正常工作 - 谢谢
@implementation QuartzView
-(IBAction)moveRight:(id)sender{
NSLog(@"Help");
lR += 50;
}
- (id)initWithFrame:(NSRect)frameRect
{
self = [super initWithFrame:frameRect];
if (self) {
}
return self;
}
- (void)drawRect:(NSRect)dirtyRect
{
CGContextRef myContext = [[NSGraphicsContext // 1
currentContext] graphicsPort];
// Drawing code here.
CGContextSetRGBFillColor (myContext, 1, 0, 0, 1);// 3
CGContextFillRect (myContext, CGRectMake (lR, 0, 200, 100 ));
[self setNeedsDisplay:YES];
}
@end
谢谢!