简单绘制与Quartz - 核心图形 [英] Simple drawing with Quartz - Core Graphics

查看:110
本文介绍了简单绘制与Quartz - 核心图形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想画一个矩形,左上角有3个子空间。类似这样的:

  _______ 
| _ | _____ |
| |
| _______ |

但是由于某种原因,我无法得到内部的两条线。

   - (void)drawRect:(CGRect)rect {
CGContextRef context = UIGraphicsGetCurrentContext
float cornerRadius = 25.0;
float w = self.bounds.size.width;
float h = self.bounds.size.height;
CGContextMoveToPoint(context,cornerRadius,0);
CGContextAddQuadCurveToPoint(context,0,0,0,cornerRadius);
CGContextAddLineToPoint(context,0,h);
CGContextAddLineToPoint(context,w,h);
CGContextAddLineToPoint(context,w,0);
CGContextAddLineToPoint(context,cornerRadius,0);

//绘图设置
CGContextSetLineWidth(context,0.5);
CGContextSetStrokeColorWithColor(context,[UIColor blackColor] .CGColor);
CGContextSetFillColorWithColor(context,[UIColor white] .CGColor);

//绘制矩形
CGContextDrawPath(context,kCGPathFillStroke);

//绘制标题/标签分区
CGContextMoveToPoint(context,TITLE_HEIGHT,0);
CGContextAddLineToPoint(context,TITLE_HEIGHT,TITLE_HEIGHT);
CGContextStrokePath(context);

//绘制标题/内容分区
CGContextMoveToPoint(context,0,TITLE_HEIGHT);
CGContextAddLineToPoint(context,self.bounds.size.width,TITLE_HEIGHT);
CGContextStrokePath(context);
}



我不知道我在这里犯错了...;

提前感谢

解决方案

尝试注释掉CGContextSetFillColorWithColor行一段时间 - 也许矩形重叠这些线?


I want to draw a rectangle with the top-left corner rounded with 3 sub-spaces in it. Something like this:

 _______
|_|_____|
|       |
|_______|

But for some reason I cannot get the inner two lines drawn.

- (void) drawRect:(CGRect)rect{
CGContextRef context = UIGraphicsGetCurrentContext();
float cornerRadius = 25.0;
float w = self.bounds.size.width;
float h = self.bounds.size.height;
CGContextMoveToPoint(context, cornerRadius, 0);
CGContextAddQuadCurveToPoint(context, 0, 0, 0, cornerRadius);
CGContextAddLineToPoint(context, 0, h);
CGContextAddLineToPoint(context, w, h);
CGContextAddLineToPoint(context, w, 0);
CGContextAddLineToPoint(context, cornerRadius, 0);

//drawing settings
CGContextSetLineWidth(context, 0.5);
CGContextSetStrokeColorWithColor(context, [UIColor blackColor].CGColor);
CGContextSetFillColorWithColor(context, [UIColor white].CGColor); 

//draw rectangle
CGContextDrawPath(context, kCGPathFillStroke);

//draw title/label partition
CGContextMoveToPoint(context, TITLE_HEIGHT, 0);
CGContextAddLineToPoint(context, TITLE_HEIGHT, TITLE_HEIGHT);
CGContextStrokePath(context);

//draw title/content partition
CGContextMoveToPoint(context, 0, TITLE_HEIGHT);
CGContextAddLineToPoint(context, self.bounds.size.width, TITLE_HEIGHT);
CGContextStrokePath(context);
}

I wonder what am I mistaking here... ;(

Thanks in advance

解决方案

Try to comment out the CGContextSetFillColorWithColor line for a while - maybe the rectangle is overlapping those lines?

这篇关于简单绘制与Quartz - 核心图形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆