NSBezierPath appendBezierPathWithArcFromPoint不会Draw

时间:2014-04-15 20:43:34

标签: macos cocoa draw nsbezierpath

我正在尝试绘制和使用" appendBezierPathWithArcFromPoint"但是在跑步时,它并没有画出弧线。 " lineToPont"作品和其他" NSBezierPath"命令工作。任何人都可以告诉我我做错了什么。我没有做出明确的答案。我使用的是MAC OS 10.9.2和XCode 5.1。下面是代码的snipet。谢谢。

#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

1 个答案:

答案 0 :(得分:0)

查看文档,似乎问题是您的fromPoint等于当前点。 docs说:

  

创建的圆弧由内切在由三个点指定的角度内的圆定义:当前点,fromPoint参数和toPoint参数(按此顺序)。

所以我认为这意味着fromPoint必须与当前点不同。