【问题标题】:NSBezierPath appendBezierPathWithArcFromPoint Wont DrawNSBezierPath appendBezierPathWithArcFromPoint 不会绘制
【发布时间】:2014-05-30 10:08:42
【问题描述】:

我正在尝试使用“appendBezierPathWithArcFromPoint”绘制弧线,但运行时,它不会绘制弧线。 “lineToPont”有效,其他“NSBezierPath”命令有效。谁能帮助我告诉我我做错了什么。我已经做了很多搜索,但没有明确的答案。我正在使用 MAC OS 10.9.2 和 XCode 5.1。下面是代码片段。谢谢。

#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

【问题讨论】:

    标签: macos cocoa draw nsbezierpath


    【解决方案1】:

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

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

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

    【讨论】:

      猜你喜欢
      • 2017-04-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-21
      相关资源
      最近更新 更多