【发布时间】:2012-07-23 07:39:57
【问题描述】:
我想在 UIView 中的图像视图(如链接图像..)之间画线。我用过
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetStrokeColorWithColor(context, [UIColor redColor].CGColor);
CGContextSetLineWidth(context, 2.0);
CGContextMoveToPoint(context, 0,0); //start at this point
CGContextAddLineToPoint(context, 20, 20); //draw to this point
CGContextStrokePath(context);
但是在这里,我的上下文是空的。我不知道是否必须导入任何框架或导入任何标题。任何建议或样品将不胜感激。
提前致谢。
【问题讨论】:
-
这段代码你在哪里写的?
-
你必须导入 Quartz 框架并在头文件中写下这个:
#import <QuartzCore/QuartzCore.h>,但是如果你没有导入它,那么你会得到编译器错误,所以这可能不是问题。 -
我建议你阅读这篇文章stackoverflow.com/questions/5847876/…
-
我在 ViewDidLoad 中写了这个
标签: iphone objective-c xcode