我有一个简单的 bezierPath,在 NSView 中有 2 个元素;我想修改按下按钮上的最后一个元素(NSPoint),但我的代码对路径没有任何视觉效果。这是我在 NSView 子类中的代码:
NSBezierPath *path;
- (void)drawRect:(NSRect)dirtyRect {
[super drawRect:dirtyRect];
// Drawing code here.
path = [NSBezierPath bezierPath];
[path moveToPoint:NSMakePoint(0, 0)];
[path lineToPoint:NSMakePoint(60, 60)];
[path setLineWith:2.0];
[[NSColor redColor] set];
[path stroke];
//the path is correctly drawing and visible
}
- (IBAction)buttonPressed:(id)sender {
NSPoint newPoint = NSMakePoint(120, 120);
[path setAssociatedPoints:&newPoint atIndex:1]; //has no visible effect
}
有什么建议吗?