我试图用"appendBezierPathWithArcFromPoint“来画和画圆弧,但是当运行的时候,它没有画出圆弧。"lineToPont“和其他"NSBezierPath”命令都有效。有没有人能帮忙告诉我我哪里做错了。我已经做了相当多的搜索,但没有明确的答案。我使用的是MacOS10.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发布于 2014-04-17 12:11:04
查看文档,似乎问题是您的fromPoint等于当前点。docs说:
创建的圆弧由一个内接在由三个点指定的角度内的圆定义:当前点、fromPoint参数和toPoint参数(按该顺序)。
所以我认为这意味着fromPoint必须与当前点不同。
https://stackoverflow.com/questions/23094140
复制相似问题