贝塞尔曲线

-(void)drawRect:(CGRect)rect

{

//    [self drawLine];

//    [self drawCurve];

    //[self drawAnotherCurve];

    //[self drawCircle];

    [self drawChangFang];

}

-(void)drawLine

{

     CGContextRef context = UIGraphicsGetCurrentContext();

    //画线条

        CGContextSetStrokeColorWithColor(context, [UIColor redColor].CGColor);//线条颜色

        CGContextSetLineWidth(context, 2.0);//线条宽度

        CGContextMoveToPoint(context, 10, 20);

        CGContextAddLineToPoint(context, 310, 20);

        CGContextStrokePath(context);

}

-(void)drawCurve

{

    CGContextRef context = UIGraphicsGetCurrentContext();

    //绘制贝玆曲线

    //贝玆曲线是通过一个起始点,两个控制点 一个结束点 来绘制函数的.

    CGContextSetLineWidth(context, 2.0);

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

    CGContextMoveToPoint(context, 10, 40);

    CGContextAddCurveToPoint(context, 20, 50, 10, 40, 300, 40);

    CGContextStrokePath(context);

}

-(void)drawAnotherCurve

{

    //连续的曲线

    CGContextRef context = UIGraphicsGetCurrentContext();

    CGContextSetLineWidth(context, 3.0);

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

    CGContextMoveToPoint(context, 10, 80);

    CGContextAddCurveToPoint(context, 50, 200, 150, 300, 300, 250);

    CGContextAddCurveToPoint(context, 300, 300, 30, 150, 40, 400);

    CGContextStrokePath(context);



}

-(void)drawCircle

{

    //画圆

    CGContextRef context = UIGraphicsGetCurrentContext();

    CGContextAddArc(context, 150, 70, 50, 0, 2*M_PI, 0);

    [[UIColor redColor]set];

    

    CGContextFillPath(context);

    



}

-(void)drawChangFang

{


    CGContextRef context = UIGraphicsGetCurrentContext();

    CGContextSetRGBStrokeColor(context, 0.8, 0.1, 0.8, 1.0);

    CGContextFillRect(context, CGRectMake(10, 10, 100, 100));

    CGContextSetLineWidth(context, 2.0);




}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值