你可以在Cocoa View中使用Core
Graphics函数,只需要传递当前图形端口:
#define cgrect(nsrect) (*(CGRect
*)&(nsrect))
- (void) drawRect: (NSRect)
rect
{
NSRect bounds
= [self bounds];
NSGraphicsContext *cocoaContext
=
[NSGraphicsContext currentContext];
CGContextRef context
= (CGContextRef)[cocoaContext graphicsPort];
CGContextSetLineWidth (context, 5.0);
CGContextBeginPath(context);
{
CGContextAddRect (context,
cgrect(bounds));
CGContextSetRGBFillColor (context, 1.0, 0.9, 0.8, 1.0);
} CGContextFillPath(context);
} // drawRec
如何在Cocoa中使用CGContext,布布扣,bubuko.com
如何在Cocoa中使用CGContext
原文:http://www.cnblogs.com/spiderdzl/p/3663291.html