#define PADDING_LEFT 7
#define PADDING_RIGHT 7
#define BTN_RIGHT 7
#define LINE_WIDTH 2
#define PADDING_TOP 15
#define BTN_WIDTH 75
#define BTN_HEIGHT 40
-(void)drawXian:(CGContextRef)context
{//画线
CGContextSetLineWidth(context,
1.0f);
const
CGFloat f[] = {0.1372, 0.1372, 0.1372, 1.0};
const
CGFloat g[] = {0.255, 0.255, 0.255, 1.0};
for
(int i= 1; i<4; i++) //横线
{
CGContextSetRGBStrokeCol or(context,
255, 100, 100, 1);
CGContextSetStrokeColor(context,
f);
CGContextMoveToPoint(context,
20 + PADDING_LEFT + BTN_WIDTH * i + LINE_WIDTH * (i-1) + 1, 50);
CGContextAddLineToPoint(context,20
+ PADDING_LEFT + BTN_WIDTH * i + LINE_WIDTH * (i-1) + 1, 156 - 15);
CGContextStrokePath(context);
}
for
(int i = 0 ; i< 3; i++) //竖线
{
CGContextSetStrokeColor(context,
g);
CGContextSetRGBStrokeCol or(context,
255, 100, 100, 1);
CGContextMoveToPoint(context,
20 + PADDING_LEFT, 0 + PADDING_TOP + BTN_HEIGHT * (i + 1) + LINE_WIDTH * i + 1);
CGContextAddLineToPoint(context,20
+ 320 - PADDING_RIGHT, 0 + PADDING_TOP + BTN_HEIGHT * (i + 1) + LINE_WIDTH * i + 1);
CGContextStrokePath(context);
}
// CGContextSetRGBStrokeCol or(context,
255, 100, 100, 1);//设置线的颜色, 如果不设置默认是黑色的
// CGContextSetLineWidth(context,
5.0);//设置线的宽度, 默认是1像纛
// CGContextSetLineCap(context,
kCGLineCapButt);
// CGContextMoveToPoint(context,
100, 100);//起使点
// CGContextAddLineToPoint(context,
200, 200);
// CGContextAddLineToPoint(context,
100, 200);
// CGContextStrokePath(context);//开始绘制
//
// CGContextSetLineWidth(context,
5);
// CGContextMoveToPoint(context,
100, 300);
// CGContextAddLineToPoint(context,
300, 300);
// CGContextStrokePath(context);
//
// CGContextSetLineWidth(context,
5);
// CGPoint
points[3];
// points[0]
= CGPointMake(200, 350);
// points[1]
= CGPointMake(300, 400);
// points[2]
= CGPointMake(200, 450);
// points[3]
= CGPointMake(100, 400);
// CGContextAddLines(context,
points, 4);//代表points这个里面有几个点 默认以第一个点为起点
//
// CGContextStrokePath(context);
}
-(void)drawYuan:(CGContextRef)context
{//画圆和椭圆
CGContextSetRGBStrokeCol or(context,
255, 100, 100, 1);
CGContextSetLineWidth(context,
5.0);
CGContextAddEllipseInRec t(context,
CGRectMake(10, 150, 300, 300));//在这个框中画圆
CGContextStrokePath(context);
}
-(void)drawArc:(CGContextRef)context
{
CGContextSetRGBStrokeCol or(context,
255, 100, 100, 1);
CGContextSetLineWidth(context,
5.0);
{
//float
pi = 3.1415926;
//CGContextAddArc(context,
160, 100, 80, 0, pi/3, 0);
}
{//Point1-Point2 Point2-Point3
以这两条线为切线的圆,半径为20... 好复杂,不知道会画出什么东西
CGContextMoveToPoint(context,
100, 100);
CGContextAddArcToPoint(context,
100, 150, 200, 100, 20);
}
CGContextStrokePath(context);
}
-(void)drawFang:(CGContextRef)context
{//画一个 Rect
CGContextSetRGBStrokeCol or(context,
255, 100, 100, 1);
CGContextSetLineWidth(context,
2.0);
CGContextAddRect(context,
CGRectMake(50, 50, 200, 300));//画一个Rect
CGRect
rcts[4];//画多个Rect
rcts[0]
= CGRectMake(100, 100, 200, 200);
rcts[1]
= CGRectMake(90, 110, 200, 200);
rcts[2]
= CGRectMake(80, 120, 200, 200);
rcts[3]
= CGRectMake(70, 130, 200, 200);
CGContextAddRects(context,
rcts, 4);//代表要画4个rect
CGContextStrokePath(context);
}
-(void)drawCurve:(CGContextRef)context
{//画曲线 比赛尔曲线
CGContextSetRGBStrokeCol or(context,
255, 100, 100, 1);
CGContextMoveToPoint(context,
50, 50);//必须有个起始点
CGContextSetLineWidth(context,
5.0);
//CGContextAddCurveToPoint (context,
100, 100, 150, 200, 150, 450);
CGContextAddQuadCurveToP oint(context,
150, 100, 300, 400);
CGContextStrokePath(context);
}
-(void)drawRect:(CGRect)rect
{
CGContextRef
context = UIGraphicsGetCurrentCont ext();
[self
drawXian:context];
[self
drawArc:context];
[self
drawCurve:context];
[self
drawFang:context];
[self
drawYuan:context];
}
#define PADDING_RIGHT 7
#define BTN_RIGHT 7
#define LINE_WIDTH 2
#define PADDING_TOP 15
#define BTN_WIDTH 75
#define BTN_HEIGHT 40
-(void)drawXian:(CGContextRef)context
{//画线
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
}
-(void)drawYuan:(CGContextRef)context
{//画圆和椭圆
}
-(void)drawArc:(CGContextRef)context
{
}
-(void)drawFang:(CGContextRef)context
{//画一个 Rect
}
-(void)drawCurve:(CGContextRef)context
{//画曲线
}
-(void)drawRect:(CGRect)rect
{
}