iphone 无法画线
我想画一条 2 像素的线..我编写了以下代码,但它没有在视图上绘制任何线或任何内容..请帮助我解决此问题或告诉我此代码中的错误...在代码 < em>pointToBeShown是CGPoint......
- (void)drawRect:(CGRect)rect {
// Drawing code.
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetLineWidth(context, 2.0);
CGContextSetStrokeColor(context, currentColor.CGColor);
pointToBeShown.x = 30;
pointToBeShown.y = 449;
CGContextMoveToPoint(context, pointToBeShown.x, pointToBeShown.y);
CGContextAddLineToPoint(context, (pointToBeShown.x + 1),( pointToBeShown.y + 1));
CGContextStrokePath(context);
}
I want to draw a line of 2 pixels..I have written the following code but it does not draw any line or anything on the view..Plzz help me regarding this or tell me the error in this code...In code pointToBeShown is CGPoint.....
- (void)drawRect:(CGRect)rect {
// Drawing code.
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetLineWidth(context, 2.0);
CGContextSetStrokeColor(context, currentColor.CGColor);
pointToBeShown.x = 30;
pointToBeShown.y = 449;
CGContextMoveToPoint(context, pointToBeShown.x, pointToBeShown.y);
CGContextAddLineToPoint(context, (pointToBeShown.x + 1),( pointToBeShown.y + 1));
CGContextStrokePath(context);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你没有收到任何警告吗?
将该行替换
为
更新:
正如您在评论中提到的那样更新
Are you not getting any warning?
Replace the line
with
Update:
Update as you mentioned in the comments