• 绘画画圆


    - (id)initWithFrame:(CGRect)frame

    {

        self = [super initWithFrame:frame];

        if (self) {

            self.frame = frame;

            _lineWidth = 3;

            self.progress = 0;

        }

        returnself;

    }

    - (void)updateProgress:(float)pro

    {

        self.progress = pro;

        [selfsetNeedsDisplay];

    //绘画

    - (void)drawRect:(CGRect)rect {

        

        CGRect allRect = self.frame;//自身大小

        CGContextRef context = UIGraphicsGetCurrentContext();//获取绘画上下文

        CGContextSetStrokeColorWithColor(context, [UIColorcolorWithHex:@"#0079ff"].CGColor);//设置绘画颜色

        float x = (allRect.size.width / 2);

        float y = (allRect.size.height / 2);//获取圆心点

        CGContextSetLineWidth(context, _lineWidth);//设置线条宽度

    //     CGContextSetLineCap(context, kCGLineCapRound);//设置线冒

        CGContextMoveToPoint(context, x, _lineWidth/2.0);// 把绘画的起始点移到园的顶部

                                         //圆心点 //半径   //开始角度     //结束角度 //顺时针

        CGContextAddArc(context, x, y, self.frame.size.width/2 - _lineWidth/2.0, -(M_PI*1/2), - M_PI* 1/2 + (2 * self.progress * M_PI), 0); ///绘画的坐标与数学的正坐标不一样,计算弧度的时候是顺时针为正弧度,逆时针是负弧度

        CGContextStrokePath(context);//完成行程路径开始绘画

    }

  • 相关阅读:
    【SQL查询】查询列中使用条件逻辑_case when then end
    【SQL查询】查询的列起别名_AS
    【SQL查询】查询的值为空时,给出默认值_NVL函数
    工薪阶层理财建议
    软件文档编写_软件开发过程中的文档
    等价边界值测试_日期
    【登录】测试用例
    来纪中的第一天
    普及C组第二题(8.1)
    普及C组第一题(8.1)
  • 原文地址:https://www.cnblogs.com/leevaboo/p/3230050.html
Copyright © 2020-2023  润新知