现在的位置: 首页 > 综合 > 正文

iphone 绘图

2013年02月23日 ⁄ 综合 ⁄ 共 2318字 ⁄ 字号 评论关闭

虚线

CGContextSetStrokeColorWithColor(myContext, [UIColor blackColor].CGColor);
CGContextSetLineDash (myContext,phase,lengths,2);
CGContextClosePath(myContext);
CGContextStrokePath(myContext);

================================================================

切线

- (void)drawRect:(CGRect)rect {

        CGContextRef context = UIGraphicsGetCurrentContext();

        CGContextSetLineWidth(context, 2.0);

        CGContextSetStrokeColorWithColor(context, [UIColor blueColor].CGColor);

        CGContextMoveToPoint(context, 100, 100);
        CGContextAddArcToPoint(context, 100,200, 300,200, 100);
        CGContextStrokePath(context);
}

================================================================

- (void)drawRect:(CGRect)rect {

        CGContextRef context = UIGraphicsGetCurrentContext();

        CGContextSetLineWidth(context, 2.0);

        CGContextSetStrokeColorWithColor(context, [UIColor blueColor].CGColor);

        CGRect rectangle = CGRectMake(60,170,200,80);

        CGContextAddEllipseInRect(context, rectangle);

        CGContextStrokePath(context);
}

================================================================

 

- (void)drawRect:(CGRect)rect {

        CGContextRef context = UIGraphicsGetCurrentContext();

        CGContextSetLineWidth(context, 2.0);

        CGContextSetStrokeColorWithColor(context, [UIColor blueColor].CGColor);

        CGContextMoveToPoint(context, 10, 10);

        CGContextAddCurveToPoint(context, 0, 50, 300, 250, 300, 400);

        CGContextStrokePath(context);
}

================================================================

 

- (void)drawRect:(CGRect)rect {

        CGContextRef context = UIGraphicsGetCurrentContext();

        CGContextSetLineWidth(context, 2.0);

        CGContextSetStrokeColorWithColor(context, [UIColor blueColor].CGColor);

        CGContextMoveToPoint(context, 10, 200);

        CGContextAddQuadCurveToPoint(context, 150, 10, 300, 200);

        CGContextStrokePath(context);
}

================================================================

 

- (void)drawRect:(CGRect)rect {

        CGContextRef context = UIGraphicsGetCurrentContext();

        CGContextSetLineWidth(context, 5.0);

        CGContextSetStrokeColorWithColor(context, [UIColor blueColor].CGColor);

        CGFloat dashArray[] = {2,6,4,2};

        CGContextSetLineDash(context, 3, dashArray, 4);

        CGContextMoveToPoint(context, 10, 200);

        CGContextAddQuadCurveToPoint(context, 150, 10, 300, 200);

        CGContextStrokePath(context);
}

抱歉!评论已关闭.