Macos NSBezierPath appendBezierPathWithArcFromPoint无法绘制
我尝试使用“appendBezierPathWithArcFromPoint”绘制和圆弧,但运行时,它不会绘制圆弧。“lineToPont”可以工作,其他“NSBezierPath”命令也可以工作。谁能告诉我我做错了什么吗。我已经讲了很多遍了,没有明确的答案。我使用的是MacOS10.9.2和XCode 5.1。下面是代码片段。多谢各位Macos NSBezierPath appendBezierPathWithArcFromPoint无法绘制,macos,cocoa,draw,nsbezierpath,Macos,Cocoa,Draw,Nsbezierpath,我尝试使用“appendBezierPathWithArcFromPoint”绘制和圆弧,但运行时,它不会绘制圆弧。“lineToPont”可以工作,其他“NSBezierPath”命令也可以工作。谁能告诉我我做错了什么吗。我已经讲了很多遍了,没有明确的答案。我使用的是MacOS10.9.2和XCode 5.1。下面是代码片段。多谢各位 #import "MyView.h" @implementation MyView - (id)initWithFrame:(NSRect)frame {
#import "MyView.h"
@implementation MyView
- (id)initWithFrame:(NSRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code here.
}
return self;
}
- (void)drawRect:(NSRect)dirtyRect
{
[super drawRect:dirtyRect];
NSRect bounds = [self bounds];
NSBezierPath *thePath = [NSBezierPath bezierPath]; // all drawing instruction goes to thePath.
[NSBezierPath setDefaultLineWidth:2.0];
[[NSColor blackColor] set];
[thePath moveToPoint:NSMakePoint(0, 0)];
[thePath lineToPoint:NSMakePoint(100, 30)];
[thePath appendBezierPathWithArcFromPoint:NSMakePoint(100,30) toPoint:NSMakePoint(130,0) radius:30];
[thePath stroke];
}
@end
查看文档,问题似乎在于您的
fromPoint
与当前点相等。他们说:
创建的圆弧由一个内接在三个点指定角度内的圆定义:当前点、fromPoint参数和toPoint参数(按该顺序)
所以我认为这意味着fromPoint
必须与当前点不同