【发布时间】: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